The result of an HTTP authentication attempt is either the user object or an HttpChallenge to present to the browser.
The result of an HTTP authentication attempt is either the user object or an HttpChallenge to present to the browser.
A PathMatcher that matches and extracts a Double value.
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 efficiently matches a number of hex-digits and extracts their (non-negative) Int value.
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) Long value.
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 digits and extracts their (non-negative) Int value.
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 matches and extracts a java.util.UUID instance.
A PathMatcher that matches and extracts a java.util.UUID instance.
A PathMatcher that efficiently matches a number of digits and extracts their (non-negative) Long value.
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 always matches, doesn't consume anything and extracts nothing.
A PathMatcher that always matches, doesn't consume anything and extracts nothing. Serves mainly as a neutral element in PathMatcher composition.
A PathMatcher that matches the very end of the requests URI path.
A PathMatcher that matches the very end of the requests URI path.
A PathMatcher that matches and extracts the complete remaining, unmatched part of the request's URI path as an (encoded!) 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.
A PathMatcher that matches and extracts the complete remaining, unmatched part of the request's URI path.
A PathMatcher that matches if the unmatched path starts with a path segment.
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 between min
and max
(both inclusively) path segments (separated by slashes)
as a 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 the given number of path segments (separated by slashes) as a List[String].
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 up to 128 remaining segments as a List[String].
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 a single slash character ('/').
A PathMatcher that matches a single slash character ('/').
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.
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).
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) 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.
Creates a PathMatcher from the given Map of path segments (prefixes) to extracted values.
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.
Returns the in-scope FromRequestUnmarshaller for the given type.
Returns the in-scope FromRequestUnmarshaller for the given type.
Extracts entity as akka.stream.scaladsl.Source of elements of type T
.
Extracts entity as akka.stream.scaladsl.Source of elements of type T
.
This is achieved by applying the implicitly provided (in the following order):
- 1st: chunk-up the incoming ByteStrings by applying the Content-Type
-aware framing
- 2nd: apply the Unmarshaller (from ByteString to T
) for each of the respective "chunks" (e.g. for each JSON element contained within an array).
The request will be rejected with an akka.http.scaladsl.server.UnsupportedRequestContentTypeRejection if
its ContentType is not supported by the used framing
or unmarshaller
.
Cancelling extracted akka.stream.scaladsl.Source closes the connection abruptly (same as cancelling the entity.dataBytes
).
See also MiscDirectives.withoutSizeLimit as you may want to allow streaming infinite streams of data in this route.
By default the uploaded data is limited by the akka.http.parsing.max-content-length
.
Extracts entity as akka.stream.scaladsl.Source of elements of type T
.
Extracts entity as akka.stream.scaladsl.Source of elements of type T
.
This is achieved by applying the implicitly provided (in the following order):
- 1st: chunk-up the incoming ByteStrings by applying the Content-Type
-aware framing
- 2nd: apply the Unmarshaller (from ByteString to T
) for each of the respective "chunks" (e.g. for each JSON element contained within an array).
The request will be rejected with an akka.http.scaladsl.server.UnsupportedRequestContentTypeRejection if
its ContentType is not supported by the used framing
or unmarshaller
.
Cancelling extracted akka.stream.scaladsl.Source closes the connection abruptly (same as cancelling the entity.dataBytes
).
See also MiscDirectives.withoutSizeLimit as you may want to allow streaming infinite streams of data in this route.
By default the uploaded data is limited by the akka.http.parsing.max-content-length
.
Wraps the inner route with Http Basic authentication support using a given Authenticator[T]
.
Wraps the inner route with Http Basic authentication support using a given Authenticator[T]
.
The given authenticator determines whether the credentials in the request are valid
and, if so, which user object to supply to the inner route.
Wraps the inner route with Http Basic authentication support.
Wraps the inner route with Http Basic authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
A directive that wraps the inner route with Http Basic authentication support.
A directive that wraps the inner route with Http Basic authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
A directive that wraps the inner route with Http Basic authentication support.
A directive that wraps the inner route with Http Basic authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. The given authenticator determines whether the credentials in the request are valid and, if so, which user object to supply to the inner route.
Lifts an authenticator function into a directive.
Lifts an authenticator function into a directive. Same as authenticateOrRejectWithChallenge
but only applies the authenticator function with a certain type of credentials.
Lifts an authenticator function into a directive.
Lifts an authenticator function into a directive. The authenticator function gets passed in credentials from the
Authorization header of the request. If the function returns Right(user)
the user object is provided
to the inner route. If the function returns Left(challenge)
the request is rejected with an
AuthenticationFailedRejection that contains this challenge to be added to the response.
Applies the given authorization check to the request.
Applies the given authorization check to the request. If the check fails the route is rejected with an AuthorizationFailedRejection.
Applies the given authorization check to the request.
Applies the given authorization check to the request. If the check fails the route is rejected with an AuthorizationFailedRejection.
Asynchronous version of authorize.
Asynchronous version of authorize.
If the Future fails or is completed with false
authorization fails and the route is rejected with an AuthorizationFailedRejection.
Asynchronous version of authorize.
Asynchronous version of authorize.
If the Future fails or is completed with false
authorization fails and the route is rejected with an AuthorizationFailedRejection.
Adds a TransformationRejection cancelling all rejections equal to the given one to the list of rejections potentially coming back from the inner route.
Adds a TransformationRejection cancelling all rejections equal to the given one to the list of rejections potentially coming back from the inner route.
Adds a TransformationRejection cancelling all rejections for which the given filter function returns true to the list of rejections potentially coming back from the inner route.
Adds a TransformationRejection cancelling all rejections for which the given filter function returns true to the list of rejections potentially coming back from the inner route.
Adds a TransformationRejection cancelling all rejections of one of the given classes to the list of rejections potentially coming back from the inner route.
Adds a TransformationRejection cancelling all rejections of one of the given classes to the list of rejections potentially coming back from the inner route.
Checks that request comes from the same origin.
Checks that request comes from the same origin. Extracts the Origin header value and verifies that allowed range contains the obtained value. In the case of absent of the Origin header rejects with MissingHeaderRejection. If the origin value is not in the allowed range rejects with an InvalidOriginRejection and StatusCodes.Forbidden status.
Completes the request using the given arguments.
Completes the request using the given arguments.
"Unwraps" a Future[T]
and runs the inner route when the future has failed
with the future's failure exception as an extraction of type Throwable
.
"Unwraps" a Future[T]
and runs the inner route when the future has failed
with the future's failure exception as an extraction of type Throwable
.
If the future succeeds the request is completed using the values marshaller
(This directive therefore requires a marshaller for the futures type to be
implicitly available.)
Uses the marshaller for the given type to produce a completion function that is passed to its inner function.
Uses the marshaller for the given type to produce a completion function that is passed to its inner function. You can use it do decouple marshaller resolution from request completion.
Tries the supplied routes in sequence, returning the result of the first route that doesn't reject the request.
Tries the supplied routes in sequence, returning the result of the first route that doesn't reject the request. This is an alternative to direct usage of the infix ~ operator. The ~ can be prone to programmer error, because if it is omitted, the program will still be syntactically correct, but will not actually attempt to match multiple routes, as intended.
subroutes to concatenate
the concatenated route
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
In particular the algorithm defined by http://tools.ietf.org/html/rfc7232#section-6 is implemented by this directive.
Note: if you want to combine this directive with withRangeSupport(...)
you need to put
it on the *outside* of the withRangeSupport(...)
directive, i.e. withRangeSupport(...)
must be on a deeper level in your route structure in order to function correctly.
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
In particular the algorithm defined by http://tools.ietf.org/html/rfc7232#section-6 is implemented by this directive.
Note: if you want to combine this directive with withRangeSupport(...)
you need to put
it on the *outside* of the withRangeSupport(...)
directive, i.e. withRangeSupport(...)
must be on a deeper level in your route structure in order to function correctly.
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
In particular the algorithm defined by http://tools.ietf.org/html/rfc7232#section-6 is implemented by this directive.
Note: if you want to combine this directive with withRangeSupport(...)
you need to put
it on the *outside* of the withRangeSupport(...)
directive, i.e. withRangeSupport(...)
must be on a deeper level in your route structure in order to function correctly.
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
Wraps its inner route with support for Conditional Requests as defined by http://tools.ietf.org/html/rfc7232
In particular the algorithm defined by http://tools.ietf.org/html/rfc7232#section-6 is implemented by this directive.
Note: if you want to combine this directive with withRangeSupport(...)
you need to put
it on the *outside* of the withRangeSupport(...)
directive, i.e. withRangeSupport(...)
must be on a deeper level in your route structure in order to function correctly.
Extracts the HttpCookiePair with the given name.
Extracts the HttpCookiePair with the given name. If the cookie is not present the request is rejected with a respective MissingCookieRejection.
Decompresses the incoming request if it is gzip
or deflate
compressed.
Decompresses the incoming request if it is gzip
or deflate
compressed.
Uncompressed requests are passed through untouched.
If the request encoded with another encoding the request is rejected with an UnsupportedRequestEncodingRejection
.
Decodes the incoming request if it is encoded with one of the given encoders.
Decodes the incoming request if it is encoded with one of the given
encoders. If the request encoding doesn't match one of the given encoders
the request is rejected with an UnsupportedRequestEncodingRejection
.
If no decoders are given the default encoders (Gzip
, Deflate
, NoCoding
) are used.
Decodes the incoming request using the given Decoder.
Decodes the incoming request using the given Decoder.
If the request encoding doesn't match the request is rejected with an UnsupportedRequestEncodingRejection
.
Rejects all non-DELETE requests.
Rejects all non-DELETE requests.
Adds a Set-Cookie response header expiring the cookie with the given properties.
Adds a Set-Cookie response header expiring the cookie with the given properties.
Adds a Set-Cookie response header expiring the given cookies.
Adds a Set-Cookie response header expiring the given cookies.
Encodes the response with the encoding that is requested by the client via the Accept-
Encoding
header.
Encodes the response with the encoding that is requested by the client via the Accept-
Encoding
header. The response encoding is determined by the rules specified in
http://tools.ietf.org/html/rfc7231#section-5.3.4.
If the Accept-Encoding
header is missing or empty or specifies an encoding other than
identity, gzip or deflate then no encoding is used.
Encodes the response with the encoding that is requested by the client via the Accept-
Encoding
header.
Encodes the response with the encoding that is requested by the client via the Accept-
Encoding
header. The response encoding is determined by the rules specified in
http://tools.ietf.org/html/rfc7231#section-5.3.4.
If the Accept-Encoding
header is missing then the response is encoded using the first
encoder.
If the Accept-Encoding
header is empty and NoCoding
is part of the encoders then no
response encoding is used. Otherwise the request is rejected.
Unmarshalls the requests entity to the given type passes it to its inner Route.
Unmarshalls the requests entity to the given type passes it to its inner Route. If there is a problem with unmarshalling the request is rejected with the Rejection produced by the unmarshaller.
Extracts a single value using the given function.
Extracts a single value using the given function.
Extracts the akka.actor.ActorSystem if the available Materializer is an akka.stream.ActorMaterializer.
Extracts the akka.actor.ActorSystem if the available Materializer is an akka.stream.ActorMaterializer. Otherwise throws an exception as it won't be able to extract the system from arbitrary materializers.
Extracts the client's IP from either the X-Forwarded-For, Remote-Address or X-Real-IP header (in that order of priority).
Extracts the client's IP from either the X-Forwarded-For, Remote-Address or X-Real-IP header (in that order of priority).
Extracts the potentially present HttpCredentials provided with the request's Authorization header.
Extracts the potentially present HttpCredentials provided with the request's Authorization header.
Extracts the entities dataBytes
akka.stream.scaladsl.Source from the akka.http.scaladsl.server.RequestContext.
Extracts the entities dataBytes
akka.stream.scaladsl.Source from the akka.http.scaladsl.server.RequestContext.
Extracts the scala.concurrent.ExecutionContextExecutor from the akka.http.scaladsl.server.RequestContext.
Extracts the scala.concurrent.ExecutionContextExecutor from the akka.http.scaladsl.server.RequestContext.
Extracts the hostname part of the Host request header value.
Extracts the hostname part of the Host request header value.
Extracts the akka.event.LoggingAdapter from the akka.http.scaladsl.server.RequestContext.
Extracts the akka.event.LoggingAdapter from the akka.http.scaladsl.server.RequestContext.
Extracts the already matched path from the RequestContext.
Extracts the already matched path from the RequestContext.
Extracts the akka.stream.Materializer from the akka.http.scaladsl.server.RequestContext.
Extracts the akka.stream.Materializer from the akka.http.scaladsl.server.RequestContext.
Extracts the request method.
Extracts the request method.
Extract the list of WebSocket subprotocols as offered by the client in the Sec-WebSocket-Protocol header if this is a WebSocket request.
Extract the list of WebSocket subprotocols as offered by the client in the Sec-WebSocket-Protocol header if this is a WebSocket request. Rejects with an ExpectedWebSocketRequestRejection, otherwise.
Extracts the akka.http.scaladsl.settings.ParserSettings from the akka.http.scaladsl.server.RequestContext.
Extracts the akka.http.scaladsl.settings.ParserSettings from the akka.http.scaladsl.server.RequestContext.
Extracts the current HttpRequest instance.
Extracts the current HttpRequest instance.
Extracts the akka.http.scaladsl.server.RequestContext itself.
Extracts the akka.http.scaladsl.server.RequestContext itself.
Extracts the akka.http.scaladsl.model.RequestEntity from the akka.http.scaladsl.server.RequestContext.
Extracts the akka.http.scaladsl.model.RequestEntity from the akka.http.scaladsl.server.RequestContext.
Extracts the Uri scheme from the request.
Extracts the Uri scheme from the request.
Extracts the RoutingSettings from the akka.http.scaladsl.server.RequestContext.
Extracts the RoutingSettings from the akka.http.scaladsl.server.RequestContext.
WARNING: This will read the entire request entity into memory regardless of size and effectively disable streaming.
WARNING: This will read the entire request entity into memory regardless of size and effectively disable streaming.
Converts the HttpEntity from the akka.http.scaladsl.server.RequestContext into an akka.http.scaladsl.model.HttpEntity.Strict and extracts it, or fails the route if unable to drain the entire request body within the timeout.
The directive is failed if the stream isn't completed after the given timeout.
Extracts the yet unmatched path from the RequestContext.
Extracts the yet unmatched path from the RequestContext.
Extract the UpgradeToWebSocket header if existent.
Extract the UpgradeToWebSocket header if existent. Rejects with an ExpectedWebSocketRequestRejection, otherwise.
Extracts the complete request URI.
Extracts the complete request URI.
Bubbles the given error up the response chain, where it is dealt with by the closest handleExceptions
directive and its ExceptionHandler.
Bubbles the given error up the response chain, where it is dealt with by the closest handleExceptions
directive and its ExceptionHandler.
Collects each body part that is a multipart file as a tuple containing metadata and a Source
for streaming the file contents somewhere.
Collects each body part that is a multipart file as a tuple containing metadata and a Source
for streaming the file contents somewhere. If there is no such field the request will be rejected,
if there are multiple file parts with the same name, the first one will be used and the subsequent
ones ignored.
Collects each body part that is a multipart file as a tuple containing metadata and a Source
for streaming the file contents somewhere.
Collects each body part that is a multipart file as a tuple containing metadata and a Source
for streaming the file contents somewhere. If there is no such field the request will be rejected.
Files are buffered into temporary files on disk so in-memory buffers don't overflow. The temporary
files are cleaned up once materialized, or on exit if the stream is not consumed.
Extracts an HTTP form field from the request.
Extracts an HTTP form field from the request. Rejects the request if the defined form field matcher(s) don't match.
Extracts HTTP form fields from the request as a
.Map[String, String]
Extracts HTTP form fields from the request as a
.
Map[String, String]
Extracts HTTP form fields from the request as a
.Map[String, List[String]]
Extracts HTTP form fields from the request as a
.
Map[String, List[String]]
Extracts HTTP form fields from the request as a
.Seq[(String, String)]
Extracts HTTP form fields from the request as a
.
Seq[(String, String)]
Extracts a number of HTTP form field from the request.
Extracts a number of HTTP form field from the request. Rejects the request if the defined form field matcher(s) don't match.
Rejects all non-GET requests.
Rejects all non-GET requests.
Serves the content of the given directories as a file system browser, i.e.
Serves the content of the given directories as a file system browser, i.e. files are sent and directories served as browseable listings.
Same as getFromBrowseableDirectories
with only one directory.
Same as getFromBrowseableDirectories
with only one directory.
Completes GET requests with the content of a file underneath the given directory.
Completes GET requests with the content of a file underneath the given directory. If the file cannot be read the Route rejects the request.
Completes GET requests with the content of the given file.
Completes GET requests with the content of the given file. If the file cannot be found or read the request is rejected.
Completes GET requests with the content of the given file.
Completes GET requests with the content of the given file. If the file cannot be found or read the request is rejected.
Completes GET requests with the content of the given file.
Completes GET requests with the content of the given file. If the file cannot be found or read the request is rejected.
Completes GET requests with the content of the given resource.
Completes GET requests with the content of the given resource. If the resource is a directory or cannot be found or read the Route rejects the request.
Completes GET requests with the content of the given class-path resource.
Completes GET requests with the content of the given class-path resource. If the resource cannot be found or read the Route rejects the request.
Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory".
Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory". If the requested resource is itself a directory or cannot be found or read the Route rejects the request.
Transforms exceptions thrown during evaluation of its inner route using the given akka.http.scaladsl.server.ExceptionHandler.
Transforms exceptions thrown during evaluation of its inner route using the given akka.http.scaladsl.server.ExceptionHandler.
Transforms rejections produced by its inner route using the given akka.http.scaladsl.server.RejectionHandler.
Transforms rejections produced by its inner route using the given akka.http.scaladsl.server.RejectionHandler.
Handles WebSocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejection.
Handles WebSocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejection.
Handles WebSocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejection.
Handles WebSocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejection.
If the subprotocol
parameter is None any WebSocket request is accepted. If the subprotocol
parameter is
Some(protocol)
a WebSocket request is only accepted if the list of subprotocols supported by the client (as
announced in the WebSocket request) contains protocol
. If the client did not offer the protocol in question
the request is rejected with an UnsupportedWebSocketSubprotocolRejection rejection.
To support several subprotocols you may chain several handleWebSocketMessagesForOptionalProtocol
routes.
Handles WebSocket requests with the given handler if the given subprotocol is offered in the request and rejects other requests with an ExpectedWebSocketRequestRejection or an UnsupportedWebSocketSubprotocolRejection.
Handles WebSocket requests with the given handler if the given subprotocol is offered in the request and rejects other requests with an ExpectedWebSocketRequestRejection or an UnsupportedWebSocketSubprotocolRejection.
Completes the request using the given function.
Completes the request using the given function. The input to the function is produced with the in-scope entity unmarshaller and the result value of the function is marshalled with the in-scope marshaller.
Rejects all non-HEAD requests.
Rejects all non-HEAD requests.
Extracts an HTTP header value using the given function.
Extracts an HTTP header value using the given function. If the function result is undefined for all headers the request is rejected with an empty rejection set. If the given function throws an exception the request is rejected with a akka.http.scaladsl.server.MalformedHeaderRejection.
Extracts the value of the HTTP request header with the given name.
Extracts the value of the HTTP request header with the given name. If no header with a matching name is found the request is rejected with a akka.http.scaladsl.server.MissingHeaderRejection.
Extracts the value of the first HTTP request header with the given name.
Extracts the value of the first HTTP request header with the given name. If no header with a matching name is found the request is rejected with a akka.http.scaladsl.server.MissingHeaderRejection.
Extracts the first HTTP request header of the given type.
Extracts the first HTTP request header of the given type. If no header with a matching type is found the request is rejected with a akka.http.scaladsl.server.MissingHeaderRejection.
Custom headers will only be matched by this directive if they extend ModeledCustomHeader and provide a companion extending ModeledCustomHeaderCompanion.
Extracts an HTTP header value using the given partial function.
Extracts an HTTP header value using the given partial function. If the function is undefined for all headers the request is rejected with an empty rejection set.
Rejects all requests with a host name that doesn't have a prefix matching the given regular expression.
Rejects all requests with a host name that doesn't have a prefix matching the given regular expression. For all matching requests the prefix string matching the regex is extracted and passed to the inner route. If the regex contains a capturing group only the string matched by this group is extracted. If the regex contains more than one capturing group an IllegalArgumentException is thrown.
Rejects all requests for whose host name the given predicate function returns false.
Rejects all requests for whose host name the given predicate function returns false.
Rejects all requests with a host name different from the given ones.
Rejects all requests with a host name different from the given ones.
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.
Returns the in-scope Marshaller for the given type.
Returns the in-scope Marshaller for the given type.
Completes GET requests with a unified listing of the contents of all given directories.
Completes GET requests with a unified listing of the contents of all given directories.
The actual rendering of the directory contents is performed by the in-scope Marshaller[DirectoryListing]
.
Produces a log entry for every incoming request.
Produces a log entry for every incoming request.
Produces a log entry for every incoming request and RouteResult.
Produces a log entry for every incoming request and RouteResult.
Produces a log entry for every RouteResult.
Produces a log entry for every RouteResult.
Runs the inner route with settings mapped by the given function.
Runs the inner route with settings mapped by the given function.
Transforms the unmatchedPath of the RequestContext using the given function.
Transforms the unmatchedPath of the RequestContext using the given function.
Rejects all requests whose HTTP method does not match the given one.
Rejects all requests whose HTTP method does not match the given one.
A PathMatcher that never matches anything.
A PathMatcher that never matches anything.
"Unwraps" a Future[T]
and runs the inner route after future
completion with the future's value as an extraction of type Try[T]
.
"Unwraps" a Future[T]
and runs the inner route after future
completion with the future's value as an extraction of type Try[T]
.
"Unwraps" a Future[T]
and runs the inner route after future
completion with the future's value as an extraction of type T
if
the supplied CircuitBreaker
is closed.
"Unwraps" a Future[T]
and runs the inner route after future
completion with the future's value as an extraction of type T
if
the supplied CircuitBreaker
is closed.
If the supplied CircuitBreaker is open the request is rejected with a CircuitBreakerOpenRejection.
"Unwraps" a Future[T]
and runs the inner route after future
completion with the future's value as an extraction of type T
.
"Unwraps" a Future[T]
and runs the inner route after future
completion with the future's value as an extraction of type T
.
If the future fails its failure Throwable is bubbled up to the nearest
ExceptionHandler.
If type T
is already a Tuple it is directly expanded into the respective
number of extractions.
Extracts the HttpCookiePair with the given name as an Option[HttpCookiePair]
.
Extracts the HttpCookiePair with the given name as an Option[HttpCookiePair]
.
If the cookie is not present a value of None
is extracted.
Extracts an optional HTTP header value using the given function.
Extracts an optional HTTP header value using the given function. If the given function throws an exception the request is rejected with a akka.http.scaladsl.server.MalformedHeaderRejection.
Extracts the value of the optional HTTP request header with the given name.
Extracts the value of the optional HTTP request header with the given name.
Extracts the value of the optional HTTP request header with the given name.
Extracts the value of the optional HTTP request header with the given name.
Extract the header value of the optional HTTP request header with the given type.
Extract the header value of the optional HTTP request header with the given type.
Custom headers will only be matched by this directive if they extend ModeledCustomHeader and provide a companion extending ModeledCustomHeaderCompanion.
Extracts an optional HTTP header value using the given partial function.
Extracts an optional HTTP header value using the given partial function. If the given function throws an exception the request is rejected with a akka.http.scaladsl.server.MalformedHeaderRejection.
Rejects all non-OPTIONS requests.
Rejects all non-OPTIONS requests.
Changes the HTTP method of the request to the value of the specified query string parameter.
Changes the HTTP method of the request to the value of the specified query string parameter. If the query string
parameter is not specified this directive has no effect. If the query string is specified as something that is not
a HTTP method, then this directive completes the request with a 501 Not Implemented
response.
This directive is useful for:
Extracts a query parameter value from the request.
Extracts a query parameter value from the request. Rejects the request if the defined query parameter matcher(s) don't match.
Due to a bug in Scala 2.10, invocations of this method sometimes fail to compile with an "too many arguments for method parameter" or "type mismatch" error.
As a workaround add an import ParameterDirectives.ParamMagnet
or use Scala 2.11.x.
Extracts the request's query parameters as a Map[String, String]
.
Extracts the request's query parameters as a Map[String, String]
.
Extracts the request's query parameters as a Map[String, List[String]]
.
Extracts the request's query parameters as a Map[String, List[String]]
.
Extracts the request's query parameters as a Seq[(String, String)]
.
Extracts the request's query parameters as a Seq[(String, String)]
.
Extracts a number of query parameter values from the request.
Extracts a number of query parameter values from the request. Rejects the request if the defined query parameter matcher(s) don't match.
Due to a bug in Scala 2.10, invocations of this method sometimes fail to compile with an "too many arguments for method parameters" or "type mismatch" error.
As a workaround add an import ParameterDirectives.ParamMagnet
or use Scala 2.11.x.
A Directive0 that always passes the request on to its inner route (i.e.
A Directive0 that always passes the request on to its inner route (i.e. does nothing with the request or the response).
Rejects all non-PATCH requests.
Rejects all non-PATCH requests.
Applies the given PathMatcher to the remaining unmatched path after consuming a leading slash.
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.
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.
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") { pathEnd { // user list ... } ~ path(UUID) { userId => // user profile ... } } } }
For further information, refer to:
https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
Applies the given PathMatcher to a prefix of the remaining unmatched path after consuming a leading slash.
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.
Checks whether the unmatchedPath of the RequestContext has a prefix matched by the given PathMatcher.
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.
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.
Applies the given PathMatcher to a suffix of the remaining unmatchedPath of the RequestContext.
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
!
Checks whether the unmatchedPath of the RequestContext has a suffix matched by the given PathMatcher.
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
!
Rejects all non-POST requests.
Rejects all non-POST requests.
Injects the given value into a directive.
Injects the given value into a directive.
Rejects all non-PUT requests.
Rejects all non-PUT requests.
Applies the given matcher directly to a prefix of the unmatched path of the RequestContext (i.e.
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.
Checks whether the unmatchedPath of the RequestContext has a prefix matched by the given PathMatcher.
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".
Completes the request with redirection response of the given type to the given URI.
Completes the request with redirection response of the given type to the given URI.
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.
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.
Rejects the request with the given rejections.
Rejects the request with the given rejections.
Rejects the request with an empty set of rejections.
Rejects the request with an empty set of rejections.
Converts responses with an empty entity into (empty) rejections.
Converts responses with an empty entity into (empty) rejections. This way you can, for example, have the marshalling of a None option be treated as if the request could not be matched.
Rejects the request with an UnsupportedRequestEncodingRejection if its encoding doesn't match the given one.
Rejects the request with an UnsupportedRequestEncodingRejection if its encoding doesn't match the given one.
Rejects if the request entity is non-empty.
Rejects if the request entity is non-empty.
Rejects with a RequestEntityExpectedRejection if the request entity is empty.
Rejects with a RequestEntityExpectedRejection if the request entity is empty. Non-empty requests are passed on unchanged to the inner route.
Adds the given response header to all HTTP responses of its inner Route, if the response from the inner Route doesn't already contain a header with the same name.
Adds the given response header to all HTTP responses of its inner Route, if the response from the inner Route doesn't already contain a header with the same name.
Adds the given response headers to all HTTP responses of its inner Route, if a header already exists it is not added again.
Adds the given response headers to all HTTP responses of its inner Route, if a header already exists it is not added again.
Adds the given response headers to all HTTP responses of its inner Route, if a header already exists it is not added again.
Adds the given response headers to all HTTP responses of its inner Route, if a header already exists it is not added again.
Unconditionally adds the given response header to all HTTP responses of its inner Route.
Unconditionally adds the given response header to all HTTP responses of its inner Route.
Unconditionally adds the given response headers to all HTTP responses of its inner Route.
Unconditionally adds the given response headers to all HTTP responses of its inner Route.
Unconditionally adds the given response headers to all HTTP responses of its inner Route.
Unconditionally adds the given response headers to all HTTP responses of its inner Route.
Rejects the request with an UnacceptedResponseEncodingRejection if the given response encoding is not accepted by the client.
Rejects the request with an UnacceptedResponseEncodingRejection if the given response encoding is not accepted by the client.
Rejects all requests whose Uri scheme does not match the given one.
Rejects all requests whose Uri scheme does not match the given one.
Inspects the request's Accept-Language
header and determines,
which of the given language alternatives is preferred by the client.
Inspects the request's Accept-Language
header and determines,
which of the given language alternatives is preferred by the client.
(See http://tools.ietf.org/html/rfc7231#section-5.3.5 for more details on the
negotiation logic.)
If there are several best language alternatives that the client
has equal preference for (even if this preference is zero!)
the order of the arguments is used as a tie breaker (First one wins).
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.
Adds a Set-Cookie response header with the given cookies.
Adds a Set-Cookie response header with the given cookies.
Streams the bytes of the file submitted using multipart with the given file name into a designated file on disk.
Streams the bytes of the file submitted using multipart with the given file name into a designated file on disk. If there is an error writing to disk the request will be failed with the thrown exception, if there is no such field the request will be rejected, if there are multiple file parts with the same name, the first one will be used and the subsequent ones ignored.
Streams the bytes of the file submitted using multipart with the given field name into designated files on disk.
Streams the bytes of the file submitted using multipart with the given field name into designated files on disk. If there is an error writing to disk the request will be failed with the thrown exception, if there is no such field the request will be rejected. Stored files are cleaned up on exit but not on failure.
Extracts a number of values using the given function.
Extracts a number of values using the given function.
WARNING: This will read the entire request entity into memory regardless of size and effectively disable streaming.
WARNING: This will read the entire request entity into memory regardless of size and effectively disable streaming.
Extracts the akka.http.scaladsl.server.RequestContext itself with the strict HTTP entity, or fails the route if unable to drain the entire request body within the timeout.
The directive is failed if the stream isn't completed after the given timeout.
Injects the given values into a directive.
Injects the given values into a directive.
Checks the given condition before running its inner route.
Checks the given condition before running its inner route. If the condition fails the route is rejected with a ValidationRejection.
Runs its inner route with the given alternative scala.concurrent.ExecutionContextExecutor.
Runs its inner route with the given alternative scala.concurrent.ExecutionContextExecutor.
Runs its inner route with the given alternative akka.event.LoggingAdapter.
Runs its inner route with the given alternative akka.event.LoggingAdapter.
Runs its inner route with the given alternative akka.stream.Materializer.
Runs its inner route with the given alternative akka.stream.Materializer.
Inspects the response entity and adds a Content-Encoding: gzip
response header if
the entity's media-type is precompressed with gzip and no Content-Encoding
header is present yet.
Inspects the response entity and adds a Content-Encoding: gzip
response header if
the entity's media-type is precompressed with gzip and no Content-Encoding
header is present yet.
Answers GET requests with an Accept-Ranges: bytes
header and converts HttpResponses coming back from its inner
route into partial responses if the initial request contained a valid Range
request header.
Answers GET requests with an Accept-Ranges: bytes
header and converts HttpResponses coming back from its inner
route into partial responses if the initial request contained a valid Range
request header. The requested
byte-ranges may be coalesced.
This directive is transparent to non-GET requests
Rejects requests with unsatisfiable ranges UnsatisfiableRangeRejection
.
Rejects requests with too many expected ranges.
Note: if you want to combine this directive with conditional(...)
you need to put
it on the *inside* of the conditional(...)
directive, i.e. conditional(...)
must be
on a higher level in your route structure in order to function correctly.
Tries to set a new request timeout and handler (if provided) at the same time.
Tries to set a new request timeout and handler (if provided) at the same time.
Due to the inherent raciness it is not guaranteed that the update will be applied before the previously set timeout has expired!
optional custom "timeout response" function. If left None, the default timeout HttpResponse will be used.
Tries to set a new request timeout and handler (if provided) at the same time.
Tries to set a new request timeout and handler (if provided) at the same time.
Due to the inherent raciness it is not guaranteed that the update will be applied before the previously set timeout has expired!
optional custom "timeout response" function. If left None, the default timeout HttpResponse will be used.
Tries to set a new request timeout and handler (if provided) at the same time.
Tries to set a new request timeout and handler (if provided) at the same time.
Due to the inherent raciness it is not guaranteed that the update will be applied before the previously set timeout has expired!
Tries to set a new request timeout handler, which produces the timeout response for a given request.
Tries to set a new request timeout handler, which produces the timeout response for a given request. Note that the handler must produce the response synchronously and shouldn't block!
Due to the inherent raciness it is not guaranteed that the update will be applied before the previously set timeout has expired!
Runs its inner route with the given alternative RoutingSettings.
Runs its inner route with the given alternative RoutingSettings.
Fails the stream with akka.http.scaladsl.model.EntityStreamSizeException if its request entity size exceeds given limit.
Fails the stream with akka.http.scaladsl.model.EntityStreamSizeException if its request entity size exceeds
given limit. Limit given as parameter overrides limit configured with akka.http.parsing.max-content-length
.
Beware that request entity size check is executed when entity is consumed.
Disables the size limit (configured by akka.http.parsing.max-content-length
by default) checking on the incoming
HttpRequest entity.
Disables the size limit (configured by akka.http.parsing.max-content-length
by default) checking on the incoming
HttpRequest entity.
Can be useful when handling arbitrarily large data uploads in specific parts of your routes.
Usage of withoutSizeLimit
is not recommended as it turns off the too large payload protection. Therefore,
we highly encourage using withSizeLimit
instead, providing it with a value high enough to successfully
handle the route in need of big entities.
Streams the bytes of the file submitted using multipart with the given file name into a temporary file on disk.
Streams the bytes of the file submitted using multipart with the given file name into a temporary file on disk. If there is an error writing to disk the request will be failed with the thrown exception, if there is no such field the request will be rejected, if there are multiple file parts with the same name, the first one will be used and the subsequent ones ignored.
(Since version 10.0.11) Deprecated in favor of storeUploadedFile which allows to specify a file to store the upload in.