Interface PathDirectives
- All Superinterfaces:
- ImplicitPathMatcherConstruction,- PathMatchers,- ToNameReceptacleEnhancements
- All Known Subinterfaces:
- Directives
- All Known Implementing Classes:
- Directives$,- HttpApp,- PathDirectives$
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic classINTERNAL APINested classes/interfaces inherited from interface org.apache.pekko.http.scaladsl.server.PathMatchersPathMatchers.HexIntNumber$, PathMatchers.HexLongNumber$, PathMatchers.IntNumber$, PathMatchers.LongNumber$, PathMatchers.NumberMatcher<T>, PathMatchers.PathEnd$, PathMatchers.Remaining$, PathMatchers.RemainingPath$, PathMatchers.Segment$, PathMatchers.Slash$
- 
Method SummaryModifier and TypeMethodDescriptionDirective<scala.runtime.BoxedUnit>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 givenPathMatcherto the remaining unmatched path after consuming a leading slash.Directive<scala.runtime.BoxedUnit>pathEnd()Rejects the request if the unmatchedPath of theRequestContextis 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>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 givenPathMatcherto a prefix of the remaining unmatched path after consuming a leading slash.<L> Directive<L>pathPrefixTest(PathMatcher<L> pm) Checks whether the unmatchedPath of theRequestContexthas a prefix matched by the given PathMatcher.Directive<scala.runtime.BoxedUnit>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 givenPathMatcherto a suffix of the remaining unmatchedPath of theRequestContext.<L> Directive<L>pathSuffixTest(PathMatcher<L> pm) Checks whether the unmatchedPath of theRequestContexthas 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 theRequestContext(i.e. without implicitly consuming a leading slash).<L> Directive<L>rawPathPrefixTest(PathMatcher<L> pm) Checks whether the unmatchedPath of theRequestContexthas 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.Methods inherited from interface org.apache.pekko.http.scaladsl.server.ImplicitPathMatcherConstruction_regex2PathMatcher, _segmentStringToPathMatcher, _stringExtractionPair2PathMatcher, _stringNameOptionReceptacle2PathMatcher, _valueMap2PathMatcherMethods inherited from interface org.apache.pekko.http.scaladsl.server.PathMatchersDoubleNumber, HexIntNumber, HexLongNumber, IntNumber, JavaUUID, LongNumber, Neutral, not, nothingMatcher, PathEnd, Remaining, RemainingPath, Segment, Segments, Segments, Segments, separateOnSlashes, SlashMethods inherited from interface org.apache.pekko.http.scaladsl.common.ToNameReceptacleEnhancements_string2NR, _symbol2NR
- 
Method Details- 
pathApplies the givenPathMatcherto the remaining unmatched path after consuming a leading slash. The matcher has to match the remaining path completely. If matched the value extracted by thePathMatcheris extracted on the directive level.- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
pathPrefixApplies the givenPathMatcherto 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.- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
rawPathPrefixApplies the given matcher directly to a prefix of the unmatched path of theRequestContext(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.- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
pathPrefixTestChecks whether the unmatchedPath of theRequestContexthas a prefix matched by the given PathMatcher. In analogy to thepathPrefixdirective a leading slash is implied.- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
rawPathPrefixTestChecks whether the unmatchedPath of theRequestContexthas a prefix matched by the given PathMatcher. However, as opposed to thepathPrefixdirective the matched path is not actually "consumed".- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
pathSuffixApplies the givenPathMatcherto a suffix of the remaining unmatchedPath of theRequestContext. If matched the value extracted by thePathMatcheris extracted and the matched parts of the path are consumed. Note that, for efficiency reasons, the givenPathMatchermust match the desired suffix in reversed-segment order, i.e.pathSuffix("baz" / "bar")would match/foo/bar/baz!- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
pathSuffixTestChecks whether the unmatchedPath of theRequestContexthas 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!- Parameters:
- pm- (undocumented)
- Returns:
- (undocumented)
 
- 
pathEndDirective<scala.runtime.BoxedUnit> pathEnd()Rejects the request if the unmatchedPath of theRequestContextis non-empty, or said differently: only passes on the request to its inner route if the request path has been matched completely.- Returns:
- (undocumented)
 
- 
pathEndOrSingleSlashDirective<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.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(org.apache.pekko.http.scaladsl.model.StatusCodes.Redirection)orredirectToNoTrailingSlashIfPresent(org.apache.pekko.http.scaladsl.model.StatusCodes.Redirection)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: 
- 
pathSingleSlashDirective<scala.runtime.BoxedUnit> pathSingleSlash()Only passes on the request to its inner route if the request path consists of exactly one remaining slash.- Returns:
- (undocumented)
 
- 
redirectToTrailingSlashIfMissingDirective<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.'''Caveat''': <L>path(org.apache.pekko.http.scaladsl.server.PathMatcher<L>)without trailing slash andpathEnd()directives will not match inside of this directive.- Parameters:
- redirectionType- (undocumented)
- Returns:
- (undocumented)
 
- 
redirectToNoTrailingSlashIfPresentDirective<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.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.orgtohttp://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.- Parameters:
- redirectionType- (undocumented)
- Returns:
- (undocumented)
 
- 
ignoreTrailingSlashDirective<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.- Returns:
- (undocumented)
 
 
-