You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the context_path field in the path attribute macro can accept a string or a variable. However, one feature that I am missing is being able to specify multiple context paths. My particular use case is that I have a single handler function that I want available via two different routes (the function itself examines the path and alters its execution based on the location). This is ideal for when I want my code to be in a 'test' mode or not ('test' is in the path).
Is there a solution to make my use case work?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
I am afraid that there is no current solution for this. This sounds a bit of a niche requirement. Even if this functionality was provided users still would need to register the handler twice in their appropriate locations. Only by giving multiple context paths, it just would end up being rendered in OpenAPI with 2 or more different paths.
What framework are you using for the web? If you are using axum or actix-web then utoipa-axum and utoipa-actix-web can help you with this. They allow you to register handlers just as they were registered normally to their Router or ServiceConfig which allow nesting or scoping in actix-web terms. For what comes to other frameworks, you are on your own.
Nevertheless perhaps this is something that can be considered in future if there is enough demand for it.
Currently, the
context_path
field in the path attribute macro can accept a string or a variable. However, one feature that I am missing is being able to specify multiple context paths. My particular use case is that I have a single handler function that I want available via two different routes (the function itself examines the path and alters its execution based on the location). This is ideal for when I want my code to be in a 'test' mode or not ('test' is in the path).Is there a solution to make my use case work?
Thanks in advance!
The text was updated successfully, but these errors were encountered: