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.