PathDirectives

pl.iterators.stir.server.directives.PathDirectives
See thePathDirectives companion object

Attributes

Companion
object
Source
PathDirectives.scala
Graph
Supertypes
trait PathMatchers
class Object
trait Matchable
class Any
Known subtypes
trait Directives
object Directives

Members list

Type members

Inherited classlikes

object HexIntNumber extends NumberMatcher[Int]

A PathMatcher that efficiently matches a number of hex-digits and extracts their (non-negative) Int value. The matcher will not match 0 digits or a sequence of digits that would represent an Int value larger than Int.MaxValue.

A PathMatcher that efficiently matches a number of hex-digits and extracts their (non-negative) Int value. The matcher will not match 0 digits or a sequence of digits that would represent an Int value larger than Int.MaxValue.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[Int]]
class Object
trait Matchable
class Any
Show all
object HexLongNumber extends NumberMatcher[Long]

A PathMatcher that efficiently matches a number of hex-digits and extracts their (non-negative) Long value. The matcher will not match 0 digits or a sequence of digits that would represent an Long value larger than Long.MaxValue.

A PathMatcher that efficiently matches a number of hex-digits and extracts their (non-negative) Long value. The matcher will not match 0 digits or a sequence of digits that would represent an Long value larger than Long.MaxValue.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[Long]]
class Object
trait Matchable
class Any
Show all
object IntNumber extends NumberMatcher[Int]

A PathMatcher that efficiently matches a number of digits and extracts their (non-negative) Int value. The matcher will not match 0 digits or a sequence of digits that would represent an Int value larger than Int.MaxValue.

A PathMatcher that efficiently matches a number of digits and extracts their (non-negative) Int value. The matcher will not match 0 digits or a sequence of digits that would represent an Int value larger than Int.MaxValue.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[Int]]
class Object
trait Matchable
class Any
Show all
object LongNumber extends NumberMatcher[Long]

A PathMatcher that efficiently matches a number of digits and extracts their (non-negative) Long value. The matcher will not match 0 digits or a sequence of digits that would represent an Long value larger than Long.MaxValue.

A PathMatcher that efficiently matches a number of digits and extracts their (non-negative) Long value. The matcher will not match 0 digits or a sequence of digits that would represent an Long value larger than Long.MaxValue.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[Long]]
class Object
trait Matchable
class Any
Show all
abstract class NumberMatcher[T](max: T, base: T)(implicit x: Integral[T]) extends PathMatcher[Tuple1[T]]

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
class PathMatcher[Tuple1[T]]
trait Path => Matching[Tuple1[T]]
class Object
trait Matchable
class Any
Known subtypes
object HexIntNumber
object HexLongNumber
object IntNumber
object LongNumber
object PathEnd extends PathMatcher[Unit]

A PathMatcher that matches the very end of the requests URI path.

A PathMatcher that matches the very end of the requests URI path.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
class PathMatcher[Unit]
trait Path => Matching[Unit]
class Object
trait Matchable
class Any
object Remaining extends PathMatcher[Tuple1[String]]

A PathMatcher that matches and extracts the complete remaining, unmatched part of the request's URI path as an (encoded!) String. If you need access to the remaining unencoded elements of the path use the RemainingPath matcher!

A PathMatcher that matches and extracts the complete remaining, unmatched part of the request's URI path as an (encoded!) String. If you need access to the remaining unencoded elements of the path use the RemainingPath matcher!

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[String]]
class Object
trait Matchable
class Any

A PathMatcher that matches and extracts the complete remaining, unmatched part of the request's URI path.

A PathMatcher that matches and extracts the complete remaining, unmatched part of the request's URI path.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[Path]]
class Object
trait Matchable
class Any
object Segment extends PathMatcher[Tuple1[String]]

A PathMatcher that matches if the unmatched path starts with a path segment. If so the path segment is extracted as a String.

A PathMatcher that matches if the unmatched path starts with a path segment. If so the path segment is extracted as a String.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
trait Path => Matching[Tuple1[String]]
class Object
trait Matchable
class Any
object Slash extends PathMatcher[Unit]

A PathMatcher that matches a single slash character ('/').

A PathMatcher that matches a single slash character ('/').

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
Supertypes
class PathMatcher[Unit]
trait Path => Matching[Unit]
class Object
trait Matchable
class Any

Value members

Concrete methods

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.

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.

Attributes

Source
PathDirectives.scala
def path[L](pm: PathMatcher[L]): Directive[L]

Applies the given 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.

Applies the given 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.

Attributes

Source
PathDirectives.scala

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.

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.

Attributes

Source
PathDirectives.scala

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.

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 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:

Attributes

See also
Source
PathDirectives.scala
def pathPrefix[L](pm: PathMatcher[L]): Directive[L]

Applies the given 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.

Applies the given 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.

Attributes

Source
PathDirectives.scala
def pathPrefixTest[L](pm: PathMatcher[L]): Directive[L]

Checks whether the unmatchedPath of the RequestContext has a prefix matched by the given PathMatcher. In analogy to the pathPrefix directive a leading slash is implied.

Checks whether the unmatchedPath of the RequestContext has a prefix matched by the given PathMatcher. In analogy to the pathPrefix directive a leading slash is implied.

Attributes

Source
PathDirectives.scala

Only passes on the request to its inner route if the request path consists of exactly one remaining slash.

Only passes on the request to its inner route if the request path consists of exactly one remaining slash.

Attributes

Source
PathDirectives.scala
def pathSuffix[L](pm: PathMatcher[L]): Directive[L]

Applies the given 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!

Applies the given 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!

Attributes

Source
PathDirectives.scala
def pathSuffixTest[L](pm: PathMatcher[L]): Directive[L]

Checks whether the unmatchedPath of the 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!

Checks whether the unmatchedPath of the 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!

Attributes

Source
PathDirectives.scala
def rawPathPrefix[L](pm: PathMatcher[L]): Directive[L]

Applies the given matcher directly to a prefix of the unmatched path of the 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.

Applies the given matcher directly to a prefix of the unmatched path of the 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.

Attributes

Source
PathDirectives.scala

Checks whether the unmatchedPath of the RequestContext has a prefix matched by the given PathMatcher. However, as opposed to the pathPrefix directive the matched path is not actually "consumed".

Checks whether the unmatchedPath of the RequestContext has a prefix matched by the given PathMatcher. However, as opposed to the pathPrefix directive the matched path is not actually "consumed".

Attributes

Source
PathDirectives.scala

If the request path ends with a slash, redirect to the same uri without trailing slash in the path.

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.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.

Attributes

Source
PathDirectives.scala

If the request path doesn't end with a slash, redirect to the same uri with trailing slash in the path.

If the request path doesn't end with a slash, redirect to the same uri with trailing slash in the path.

'''Caveat''': path without trailing slash and pathEnd directives will not match inside of this directive.

Attributes

Source
PathDirectives.scala

Inherited methods

def Segments(min: Int, max: Int): PathMatcher1[List[String]]

A PathMatcher that matches between min and max (both inclusively) path segments (separated by slashes) as a List[String]. If there are more than count segments present the remaining ones will be left unmatched. If the path has a trailing slash this slash will not be matched.

A PathMatcher that matches between min and max (both inclusively) path segments (separated by slashes) as a List[String]. If there are more than count segments present the remaining ones will be left unmatched. If the path has a trailing slash this slash will not be matched.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

A PathMatcher that matches the given number of path segments (separated by slashes) as a List[String]. If there are more than count segments present the remaining ones will be left unmatched. If the path has a trailing slash this slash will not be matched.

A PathMatcher that matches the given number of path segments (separated by slashes) as a List[String]. If there are more than count segments present the remaining ones will be left unmatched. If the path has a trailing slash this slash will not be matched.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
def not(self: PathMatcher[_]): PathMatcher0

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

A PathMatcher that never matches anything.

A PathMatcher that never matches anything.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

Converts a path string containing slashes into a PathMatcher that interprets slashes as path segment separators.

Converts a path string containing slashes into a PathMatcher that interprets slashes as path segment separators.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

Inherited fields

A PathMatcher that matches and extracts a Double value. The matched string representation is the pure decimal, optionally signed form of a double value, i.e. without exponent.

A PathMatcher that matches and extracts a Double value. The matched string representation is the pure decimal, optionally signed form of a double value, i.e. without exponent.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala
val JavaUUID: PathMatcher1[UUID]

A PathMatcher that matches and extracts a java.util.UUID instance.

A PathMatcher that matches and extracts a java.util.UUID instance.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

A PathMatcher that always matches, doesn't consume anything and extracts nothing. Serves mainly as a neutral element in PathMatcher composition.

A PathMatcher that always matches, doesn't consume anything and extracts nothing. Serves mainly as a neutral element in PathMatcher composition.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

A PathMatcher that matches up to 128 remaining segments as a List[String]. This can also be no segments resulting in the empty list. If the path has a trailing slash this slash will not be matched.

A PathMatcher that matches up to 128 remaining segments as a List[String]. This can also be no segments resulting in the empty list. If the path has a trailing slash this slash will not be matched.

Attributes

Inherited from:
PathMatchers
Source
PathMatcher.scala

Implicits

Inherited implicits

implicit def _regex2PathMatcher(regex: Regex): PathMatcher1[String]

Creates a PathMatcher that consumes (a prefix of) the first path segment if the path begins with a segment (a prefix of) which matches the given regex. Extracts either the complete match (if the regex doesn't contain a capture group) or the capture group (if the regex contains exactly one). If the regex contains more than one capture group the method throws an IllegalArgumentException.

Creates a PathMatcher that consumes (a prefix of) the first path segment if the path begins with a segment (a prefix of) which matches the given regex. Extracts either the complete match (if the regex doesn't contain a capture group) or the capture group (if the regex contains exactly one). If the regex contains more than one capture group the method throws an IllegalArgumentException.

Attributes

Inherited from:
ImplicitPathMatcherConstruction
Source
PathMatcher.scala

Creates a PathMatcher that consumes (a prefix of) the first path segment (if the path begins with a segment).

Creates a PathMatcher that consumes (a prefix of) the first path segment (if the path begins with a segment).

Attributes

Inherited from:
ImplicitPathMatcherConstruction
Source
PathMatcher.scala
implicit def _stringExtractionPair2PathMatcher[T](tuple: (String, T)): PathMatcher1[T]

Creates a PathMatcher that consumes (a prefix of) the first path segment (if the path begins with a segment) and extracts a given value.

Creates a PathMatcher that consumes (a prefix of) the first path segment (if the path begins with a segment) and extracts a given value.

Attributes

Inherited from:
ImplicitPathMatcherConstruction
Source
PathMatcher.scala
implicit def _valueMap2PathMatcher[T](valueMap: Map[String, T]): PathMatcher1[T]

Creates a PathMatcher from the given Map of path segments (prefixes) to extracted values. If the unmatched path starts with a segment having one of the maps keys as a prefix the matcher consumes this path segment (prefix) and extracts the corresponding map value. For keys sharing a common prefix the longest matching prefix is selected.

Creates a PathMatcher from the given Map of path segments (prefixes) to extracted values. If the unmatched path starts with a segment having one of the maps keys as a prefix the matcher consumes this path segment (prefix) and extracts the corresponding map value. For keys sharing a common prefix the longest matching prefix is selected.

Attributes

Inherited from:
ImplicitPathMatcherConstruction
Source
PathMatcher.scala