Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 'endpoint' attribute of request object #977

Closed
olexandr-klymenko opened this issue Oct 16, 2017 · 1 comment
Closed

Implement 'endpoint' attribute of request object #977

olexandr-klymenko opened this issue Oct 16, 2017 · 1 comment

Comments

@olexandr-klymenko
Copy link

In my use case I need to have the endpoint attribute in request object which should contain name of coro (1-st argument of endpoint coro) similarly to Flask request.endpoint, i.e.:

@app.middleware('response')
def _after_request(request, response):

    def make_request_id():
        return '.'.join([request.endpoint, request.method.lower(), str(uuid4())])

    request_id = make_request_id()
    response.headers[REQUEST_ID_HEADER] = request_id
    return response

endpoint can be automatically created with blueprint decorator:

@blueprint.get("", strict_slashes=True)
async def get_profile(request):
    return response.json({
        'user_id': '0',
        'profile_id': 0,
        'nickname': 'Nickname'
    }, 200)

i.e. in this case request.endpoint is 'get_profile'

@ahopkins
Copy link
Member

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants