-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow optional path segments #1054
Comments
Interesting idea. How would we handle the case of |
I think the optional scenario would only match in case the last path segment is both a parameter and missing... |
It is possible to use multiple patterns for resource in 2.0 App::new().service(web::resource([‘path1’, ‘path2/{name}/‘]).to(...) |
Which method signature is needed for a resource with multiple patterns and optional path segment? |
@ChriFo i don’t think this is supported with extractors. You would need to pass HttpRequest and use match_info to distinguish between the cases |
How to do for |
@s97712 Currently, it's not possible to provide multiple paths using the macros. PRs welcome. |
I was wondering how to implement a query for either a collection or a subresource, using the same handler. For example, say we have
/products
and/products/{product_id}
-- it is currently impossible to manage both in the same handler conveniently.I was wondering if it could be possible to use
web::Path<Option<String>>
for such cases, and have the handler check if a product id was specified in the URL. If that sounds reasonable I can try and craft a PR for it.The text was updated successfully, but these errors were encountered: