-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add Hooks::before_routes to give user control over initial axum::Router construction #646
Conversation
@swlody this is really great! "before lunch" (getting food, getting place to eat) It doesn't always work to "force" things into that kind of shape and form but in this case, I think it might be. I feel this PR (covering how to customize fallbacks, etc), is actually:
Where the user will
if the user wants to add stuff "after", they can use after_routes, as you've already identified This keeps the complexity of "wait, after I built a new router, how to I add the routes?, what are the steps I need to follow to get to a fully working router? do I need to also call By offering the user just the thing they need ("e.g. use So to summarize:
Hope this wasn't too long, makes sense? |
Thanks for the detailed feedback @jondot. I've renamed to |
thanks @swlody |
This function can be implemented by the user to fully control the construction of the axum router before it is handed back to loco. This is necessary in order to create a fallback handler that is covered by the loco middleware, as any fallback that is added in
after_routes
gets initialized after all the middleware into_router
. The default implementation ofHooks::before_routes
results in the same behavior as before, but the user can override the implementation like so:Resolves #643