public interface PathDirectives extends PathMatchers, ImplicitPathMatcherConstruction, ToNameReceptacleEnhancements
Modifier and Type | Interface and Description |
---|---|
static class |
PathDirectives.TrailingRetryRejection$
INTERNAL API
|
PathMatchers.HexIntNumber$, PathMatchers.HexLongNumber$, PathMatchers.IntNumber$, PathMatchers.LongNumber$, PathMatchers.NumberMatcher<T>, PathMatchers.PathEnd$, PathMatchers.Remaining$, PathMatchers.RemainingPath$, PathMatchers.Segment$, PathMatchers.Slash$
Modifier and Type | Method and Description |
---|---|
Directive<scala.runtime.BoxedUnit> |
ignoreTrailingSlash()
Tries to match the inner route and if it fails with an empty rejection, it tries it again
adding (or removing) the trailing slash on the given path.
|
<L> Directive<L> |
path(PathMatcher<L> pm)
Applies the given
PathMatcher to the remaining unmatched path after consuming a leading slash. |
Directive<scala.runtime.BoxedUnit> |
pathEnd()
Rejects the request if the unmatchedPath of the
RequestContext is non-empty,
or said differently: only passes on the request to its inner route if the request path
has been matched completely. |
Directive<scala.runtime.BoxedUnit> |
pathEndOrSingleSlash()
Only passes on the request to its inner route if the request path has been matched
completely or only consists of exactly one remaining slash.
|
<L> Directive<L> |
pathPrefix(PathMatcher<L> pm)
Applies the given
PathMatcher to a prefix of the remaining unmatched path after consuming a leading slash. |
<L> Directive<L> |
pathPrefixTest(PathMatcher<L> pm)
Checks whether the unmatchedPath of the
RequestContext has a prefix matched by the
given PathMatcher. |
Directive<scala.runtime.BoxedUnit> |
pathSingleSlash()
Only passes on the request to its inner route if the request path
consists of exactly one remaining slash.
|
<L> Directive<L> |
pathSuffix(PathMatcher<L> pm)
Applies the given
PathMatcher to a suffix of the remaining unmatchedPath of the RequestContext . |
<L> Directive<L> |
pathSuffixTest(PathMatcher<L> pm)
Checks whether the unmatchedPath of the
RequestContext has a suffix matched by the
given PathMatcher. |
<L> Directive<L> |
rawPathPrefix(PathMatcher<L> pm)
Applies the given matcher directly to a prefix of the unmatched path of the
RequestContext (i.e. without implicitly consuming a leading slash). |
<L> Directive<L> |
rawPathPrefixTest(PathMatcher<L> pm)
Checks whether the unmatchedPath of the
RequestContext has a prefix matched by the
given PathMatcher. |
Directive<scala.runtime.BoxedUnit> |
redirectToNoTrailingSlashIfPresent(StatusCodes.Redirection redirectionType)
If the request path ends with a slash, redirect to the same uri without trailing slash in the path.
|
Directive<scala.runtime.BoxedUnit> |
redirectToTrailingSlashIfMissing(StatusCodes.Redirection redirectionType)
If the request path doesn't end with a slash, redirect to the same uri with trailing slash in the path.
|
DoubleNumber, HexIntNumber, HexLongNumber, IntNumber, JavaUUID, LongNumber, Neutral, not, nothingMatcher, PathEnd, Remaining, RemainingPath, Segment, Segments, Segments, Segments, separateOnSlashes, Slash
_regex2PathMatcher, _segmentStringToPathMatcher, _stringExtractionPair2PathMatcher, _stringNameOptionReceptacle2PathMatcher, _valueMap2PathMatcher
_string2NR, _symbol2NR
<L> Directive<L> path(PathMatcher<L> pm)
PathMatcher
to the remaining unmatched path after consuming a leading slash.
The matcher has to match the remaining path completely.
If matched the value extracted by the PathMatcher
is extracted on the directive level.
pm
- (undocumented)<L> Directive<L> pathPrefix(PathMatcher<L> pm)
PathMatcher
to a prefix of the remaining unmatched path after consuming a leading slash.
The matcher has to match a prefix of the remaining path.
If matched the value extracted by the PathMatcher is extracted on the directive level.
pm
- (undocumented)<L> Directive<L> rawPathPrefix(PathMatcher<L> pm)
RequestContext
(i.e. without implicitly consuming a leading slash).
The matcher has to match a prefix of the remaining path.
If matched the value extracted by the PathMatcher is extracted on the directive level.
pm
- (undocumented)<L> Directive<L> pathPrefixTest(PathMatcher<L> pm)
RequestContext
has a prefix matched by the
given PathMatcher. In analogy to the pathPrefix
directive a leading slash is implied.
pm
- (undocumented)<L> Directive<L> rawPathPrefixTest(PathMatcher<L> pm)
RequestContext
has a prefix matched by the
given PathMatcher. However, as opposed to the pathPrefix
directive the matched path is not
actually "consumed".
pm
- (undocumented)<L> Directive<L> pathSuffix(PathMatcher<L> pm)
PathMatcher
to a suffix of the remaining unmatchedPath of the RequestContext
.
If matched the value extracted by the PathMatcher
is extracted and the matched parts of the path are consumed.
Note that, for efficiency reasons, the given PathMatcher
must match the desired suffix in reversed-segment
order, i.e. pathSuffix("baz" / "bar")
would match /foo/bar/baz
!
pm
- (undocumented)<L> Directive<L> pathSuffixTest(PathMatcher<L> pm)
RequestContext
has a suffix matched by the
given PathMatcher. However, as opposed to the pathSuffix directive the matched path is not
actually "consumed".
Note that, for efficiency reasons, the given PathMatcher must match the desired suffix in reversed-segment
order, i.e. pathSuffixTest("baz" / "bar")
would match /foo/bar/baz
!
pm
- (undocumented)Directive<scala.runtime.BoxedUnit> pathEnd()
RequestContext
is non-empty,
or said differently: only passes on the request to its inner route if the request path
has been matched completely.
Directive<scala.runtime.BoxedUnit> pathEndOrSingleSlash()
Note that trailing slash and non-trailing slash URLs are '''not''' the same, although they often serve
the same content. It is recommended to serve only one URL version and make the other redirect to it using
redirectToTrailingSlashIfMissing
or redirectToNoTrailingSlashIfPresent
directive.
For example:
def route = {
// redirect '/users/' to '/users', '/users/:userId/' to '/users/:userId'
redirectToNoTrailingSlashIfPresent(Found) {
pathPrefix("users") {
concat(
pathEnd {
// user list ...
},
path(UUID) { userId =>
// user profile ...
}
)
}
}
}
For further information, refer to:
Directive<scala.runtime.BoxedUnit> pathSingleSlash()
Directive<scala.runtime.BoxedUnit> redirectToTrailingSlashIfMissing(StatusCodes.Redirection redirectionType)
'''Caveat''': path
without trailing slash and pathEnd
directives will not match inside of this directive.
redirectionType
- (undocumented)Directive<scala.runtime.BoxedUnit> redirectToNoTrailingSlashIfPresent(StatusCodes.Redirection redirectionType)
Note, however, that this directive doesn't apply to a URI consisting of just a single slash.
HTTP does not support empty target paths, so that browsers will convert
a URI such as http://example.org
to http://example.org/
adding the trailing slash.
Redirecting the single slash path URI would lead to a redirection loop.
'''Caveat''': pathSingleSlash
directive will only match on the root path level inside of this directive.
redirectionType
- (undocumented)Directive<scala.runtime.BoxedUnit> ignoreTrailingSlash()