Compare commits
No commits in common. "6a27b002ffa4676d3a807092ff7b10f2ded3fe54" and "e2d73932c04ebeda71a7972327f2dbcecf4b140e" have entirely different histories.
6a27b002ff
...
e2d73932c0
|
@ -29,8 +29,7 @@ def create_context(request):
|
||||||
|
|
||||||
|
|
||||||
def register(version: str,
|
def register(version: str,
|
||||||
path: str,
|
path: str):
|
||||||
):
|
|
||||||
""" Decorator to register function to the http route
|
""" Decorator to register function to the http route
|
||||||
"""
|
"""
|
||||||
def decorator(function):
|
def decorator(function):
|
||||||
|
@ -42,9 +41,7 @@ def register(version: str,
|
||||||
|
|
||||||
|
|
||||||
class extra_route_handler:
|
class extra_route_handler:
|
||||||
async def __new__(cls,
|
async def __new__(cls, request):
|
||||||
request,
|
|
||||||
):
|
|
||||||
kwargs = dict(request.match_info)
|
kwargs = dict(request.match_info)
|
||||||
kwargs['request'] = request
|
kwargs['request'] = request
|
||||||
kwargs['risotto_context'] = create_context(request)
|
kwargs['risotto_context'] = create_context(request)
|
||||||
|
@ -99,13 +96,11 @@ async def handle(request):
|
||||||
print_exc()
|
print_exc()
|
||||||
raise HTTPInternalServerError(reason=str(err))
|
raise HTTPInternalServerError(reason=str(err))
|
||||||
return Response(text=dumps({'response': text}),
|
return Response(text=dumps({'response': text}),
|
||||||
content_type='application/json',
|
content_type='application/json')
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def api(request,
|
async def api(request,
|
||||||
risotto_context,
|
risotto_context):
|
||||||
):
|
|
||||||
global TIRAMISU
|
global TIRAMISU
|
||||||
if not TIRAMISU:
|
if not TIRAMISU:
|
||||||
# check all URI that have an associated role
|
# check all URI that have an associated role
|
||||||
|
@ -157,8 +152,7 @@ async def get_app(loop):
|
||||||
for version in versions:
|
for version in versions:
|
||||||
api_route = {'function': api,
|
api_route = {'function': api,
|
||||||
'version': version,
|
'version': version,
|
||||||
'path': f'/api/{version}',
|
'path': f'/api/{version}'}
|
||||||
}
|
|
||||||
extra_handler = type(api_route['path'], (extra_route_handler,), api_route)
|
extra_handler = type(api_route['path'], (extra_route_handler,), api_route)
|
||||||
routes.append(get(api_route['path'], extra_handler))
|
routes.append(get(api_route['path'], extra_handler))
|
||||||
print(f' - {api_route["path"]} (http_get)')
|
print(f' - {api_route["path"]} (http_get)')
|
||||||
|
|
Loading…
Reference in New Issue