kopia lustrzana https://github.com/cirospaciari/socketify.py
just some parameter changes in middleware async
rodzic
87abd89f7d
commit
48e92f600e
|
@ -7,7 +7,7 @@ async def get_user(authorization):
|
||||||
return { 'greeting': 'Hello, World' }
|
return { 'greeting': 'Hello, World' }
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def auth(home, queries=[]):
|
def auth(route, queries=[]):
|
||||||
#in async query string, arguments and headers are only valid until the first await
|
#in async query string, arguments and headers are only valid until the first await
|
||||||
async def auth_middleware(res, req):
|
async def auth_middleware(res, req):
|
||||||
#get_headers will preserve headers (and cookies) after await
|
#get_headers will preserve headers (and cookies) after await
|
||||||
|
@ -24,7 +24,7 @@ def auth(home, queries=[]):
|
||||||
|
|
||||||
user = await get_user(headers.get('authorization', None))
|
user = await get_user(headers.get('authorization', None))
|
||||||
if user:
|
if user:
|
||||||
return home(res, req, user, query_data)
|
return route(res, req, user, query_data)
|
||||||
|
|
||||||
return res.write_status(403).cork_end("not authorized")
|
return res.write_status(403).cork_end("not authorized")
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue