-
Notifications
You must be signed in to change notification settings - Fork 322
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
Permit routing without invoking actions #155
Comments
Named routes would solve the having an identifier for the route, but it doesn't address the rest of the request. |
Could you say more about the use-case here? It wouldn't be hard to do routing without invoking any code, but it's not quite clear to me what the end goal is. |
I think @jjl are looking forward to features similar to extractors in actix-web, where desired params are automatically passed to the endpoint function without the needs to be extracted manually from An example from the actix-web docs: use actix_web::{App, Path, Result, http};
/// extract path info from "/users/{userid}/{friend}" url
/// {userid} - - deserializes to a u32
/// {friend} - deserializes to a String
fn index(info: Path<(u32, String)>) -> Result<String> {
Ok(format!("Welcome {}! {}", info.1, info.0))
}
fn main() {
let app = App::new().resource(
"/users/{userid}/{friend}", // <- define path parameters
|r| r.method(http::Method::GET).with(index)); // <- use `with` extractor
} . It is not necessary at all as a matter of capabilities. But it does help reduce a lot of boilerplate codes. |
I didn't see anything in the router blog post, but one of the commonly requested features in other web frameworks across various languages is to be able to use the router without invoking code.
For example, given a route
/foo/:bar
and a path/foo/quux
, one would ideally be able to obtain some sort of identifier for the route and the mappingbar
->quux
.One initial problem would seem to be that there is no natural identifier for the route.
The text was updated successfully, but these errors were encountered: