I have a test server that takes expectations at runtime and responds accordingly when the expectation is called. The expectations are stored in state. Here's the route:
val route: Route = ctx => {
val routes = state.map { case (pathString, responses) =>
get {
path(pathString) {
...
}
}
}
concat(routes: _*)(ctx)
}
This approach works when the expected path does not have any slashes, e.g. foo.html. But when it has a fuller path, e.g. foo/bar.html, then the directive will not match.
How can I correctly convert the given path string into a PathMatcher?
I have tried pathString.split("/").foldLeft(Neutral)(_ / _) but this caused the simple case of foo.html to fail.
PathMatchers.separateOnSlashes(String) is provided by the library and does what I need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With