-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
Regex pattern matching route parameters #19
Comments
You could make a stronger type than a generic regex, by using struct Something;
impl FromStr for Something {
type Err = ();
fn from_str(s: &str) -> Result<Something, ()> {
match s {
"value1" | "value2" => Ok(Something),
_ => Err(())
}
}
}
let something = warp::path::param::<Something>(); |
@seanmonstar interesting, so an error will just 404 the request? |
Yep! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It might be that there's a way to do this by composing filters, but it seems to escape me for the moment.
If I have a route of
/:something
, is there a way to provide a pattern to filter? For example, say I wanted to accept/:something
, but only where:something
isvalue1
orvalue2
. It seems I could maybe join some handlers up together to make this happen, but not in a way that would provide access to the value of:something
?The text was updated successfully, but these errors were encountered: