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

Global request guards #1709

Closed
KennethGomez opened this issue Jun 17, 2021 · 2 comments
Closed

Global request guards #1709

KennethGomez opened this issue Jun 17, 2021 · 2 comments
Labels
question A question (converts to discussion)

Comments

@KennethGomez
Copy link

I've run into a issue on which my Rocket application needs some sort of guard for all routes and I don't find anywhere on documentation to do it.

I've tested doing a Fairing that then calls a guard with request.guard method, but I still don't know how to process the outcome the guard produces, how to abort the request on that Fairing.

Is there any way to achieve this?

Thank you in advance.

@jebrosen
Copy link
Collaborator

I've tested doing a Fairing that then calls a guard with request.guard method, but I still don't know how to process the outcome the guard produces, how to abort the request on that Fairing.

Fairings cannot directly influence routing or respond early. #749 includes a proposal that would make Fairings able to return a Response or Responder directly, but it hasn't yet been implemented.

Is there any way to achieve this?

One current workaround is that an on_request fairing can change the request URI (with set_uri) to a particular predefined route.

@jebrosen jebrosen added the question A question (converts to discussion) label Jun 21, 2021
@KennethGomez
Copy link
Author

Thank you very much for your help, you can close this issue as the workaround is valid for me, and I'll be waiting for the Fairing implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question (converts to discussion)
Projects
None yet
Development

No branches or pull requests

2 participants