Reputation: 2382
I'd like to write a path matcher that matches any of the remaining parts of the path with a regex, so for example,
path("myregex".r)
would match if i have remaining paths in the form:
/myregex
/foo/myregex
/foo/myregex/bar
/myregex/bar
I looked at the code for the regex matcher, it seems like it only looks at the first segment, I could setup multiple routes or write a custom matcher, but was wondering if there is already a better solution for it?
Thanks,
Upvotes: 2
Views: 931
Reputation: 718
How about this?
path(Segments){segments=>
validate(segments.exists(_.matches("myregex")), "unmatched path"){
complete(s"matched: $segments")
}
}
Upvotes: 1