unmatchedPath
Extracts the unmatched path from the request context.
Signature
def unmatchedPath: Directive1[Uri.Path]
Description
The unmatchedPath
directive extracts the remaining path that was not yet matched by any of the PathDirectives
(or any custom ones that change the unmatched path field of the request context). You can use it for building directives
that handle complete suffixes of paths (like the getFromDirectory
directives and similar ones).
Use rewriteUnmatchedPath
to change the value of the unmatched path.
Example
val route =
pathPrefix("abc") {
unmatchedPath { remaining =>
complete(s"Unmatched: '$remaining'")
}
}
Get("/abc") ~> route ~> check {
responseAs[String] === "Unmatched: ''"
}
Get("/abc/456") ~> route ~> check {
responseAs[String] === "Unmatched: '/456'"
}