pathEnd
Only passes the request to its inner route if the unmatched path of the RequestContext is empty, i.e. the request path has been fully matched by a higher-level path or pathPrefix directive.
Signature
def pathEnd: Directive0
Description
This directive is a simple alias for rawPathPrefix(PathEnd) and is mostly used on an inner-level to discriminate “path already fully matched” from other alternatives (see the example below).
Example
val route =
pathPrefix("foo") {
pathEnd {
complete("/foo")
} ~
path("bar") {
complete("/foo/bar")
}
}
Get("/foo") ~> route ~> check {
responseAs[String] === "/foo"
}
Get("/foo/") ~> route ~> check {
handled === false
}
Get("/foo/bar") ~> route ~> check {
responseAs[String] === "/foo/bar"
}