Move route_show_if into decorators

Also removes unused route_hide_if
This commit is contained in:
Joseph Schorr 2017-07-20 11:07:31 -04:00
parent ed3ba07830
commit 17f3de811e
9 changed files with 24 additions and 46 deletions

View file

@ -15,7 +15,7 @@ from auth.auth_context import get_grant_context
from auth.permissions import (
ReadRepositoryPermission, ModifyRepositoryPermission, AdministerRepositoryPermission)
from auth.registry_jwt_auth import process_registry_jwt_auth, get_auth_headers
from endpoints.decorators import anon_protect, anon_allowed
from endpoints.decorators import anon_protect, anon_allowed, route_show_if
from endpoints.v2.errors import V2RegistryException, Unauthorized, Unsupported, NameUnknown
from endpoints.v2.models_pre_oci import data_model as model
from util.http import abort
@ -126,20 +126,6 @@ def get_input_stream(flask_request):
return flask_request.stream
def route_show_if(value):
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if not value:
abort(404)
return f(*args, **kwargs)
return decorated_function
return decorator
@v2_bp.route('/')
@route_show_if(features.ADVERTISE_V2)
@process_registry_jwt_auth()