Predefined Directives (alphabetically) • Akka HTTP (original) (raw)
Wraps its inner Route with caching support using the given CacheCache implementation and the in-scope keyer function.
Extracts the value of the request attribute with a given key
Wraps the inner route with Http Basic authentication support using a given Authenticator[T]
Authenticator<T>
Wraps the inner route with Http Basic authentication support using a given AsyncAuthenticator[T]
AsyncAuthenticator<T>
Wraps the inner route with Http Basic authentication support using a given AuthenticatorPF[T]
AuthenticatorPF<T>
Wraps the inner route with Http Basic authentication support using a given AsyncAuthenticatorPF[T]
AsyncAuthenticatorPF<T>
Wraps the inner route with OAuth Bearer Token authentication support using a given AuthenticatorPF[T]
AuthenticatorPF<T>
Wraps the inner route with OAuth Bearer Token authentication support using a given AsyncAuthenticator[T]
AsyncAuthenticator<T>
Wraps the inner route with OAuth Bearer Token authentication support using a given AuthenticatorPF[T]
AuthenticatorPF<T>
Wraps the inner route with OAuth Bearer Token authentication support using a given AsyncAuthenticatorPF[T]
AsyncAuthenticatorPF<T>
authenticateOrRejectWithChallenge
Lifts an authenticator function into a directive
Applies the given authorization check to the request
Applies the given asynchronous authorization check to the request
Wraps its inner Route with caching support using the given CacheCache implementation and the in-scope keyer function.
Passes only requests that explicitly forbid caching with a Cache-Control
header with either a no-cache
or max-age=0
setting.
Adds a TransformationRejectionTransformationRejection cancelling all rejections equal to the given one to the rejections potentially coming back from the inner route.
Adds a TransformationRejectionTransformationRejection cancelling all matching rejections to the rejections potentially coming back from the inner route
Checks that the request comes from the same origin
Completes the request using the given arguments
“Unwraps” a Future[T]
CompletionStage<T>
and runs the inner route when the future has failed with the error as an extraction of type Throwable
Uses the marshaller for a given type to extract a completion function
Wraps its inner route with support for conditional requests as defined by RFC 7232
Extracts the HttpCookieHttpCookie with the given name
Wrapps its inner route with CORS handling
Decompresses the request if it is gzip
or deflate
compressed
Decodes the incoming request using one of the given decoders
Rejects all non-DELETE requests
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 (NoCoding
, Gzip
and Deflate
)
Encodes the response with the encoding that is requested by the client via the Accept-Encoding
header (from a user-defined set)
Extracts the request entity unmarshalled to a given type
Extracts a single value using a RequestContext => T
Function<RequestContext, T>
function
Extracts the entities data bytes as a stream Source<ByteString, ?>Source[ByteString, _]
Extracts the client’s IP from either the X-Forwarded-
, Remote-Address
or X-Real-IP
header
Extracts the client cert for an mTLS request
Extracts the client’s IP from either the X-Forwarded-
, Remote-Address
or X-Real-IP
header
Extracts the potentially present HttpCredentialsHttpCredentials provided with the request’s AuthorizationAuthorization header
Extracts the ExecutionContext
from the RequestContextRequestContext
Extracts the already matched path from the RequestContextRequestContext
Extracts the MaterializerMaterializer from the RequestContextRequestContext
Extracts the hostname part of the Host request header value
Extracts the LoggingAdapterLoggingAdapter from the RequestContextRequestContext
Extracts the request method
Extract the list of websocket subprotocols offered by the client in the Sec-WebSocket-Protocol
header if this is a websocket request and otherwise rejects with an ExpectedWebSocketRequestRejectionExpectedWebSocketRequestRejection
Extracts the ParserSettingsParserSettings from the RequestContextRequestContext
Extracts the current HttpRequestHttpRequest instance
Extracts the RequestContextRequestContext itself
Extracts the RequestEntityRequestEntity from the RequestContextRequestContext
Extracts the URI scheme from the request
Extracts the RoutingSettingsRoutingSettings from the RequestContextRequestContext
Extracts the SSL session for a HTTPS request
Extracts the yet unmatched path from the RequestContextRequestContext
Extract the UpgradeToWebSocketUpgradeToWebSocket header if existent and otherwise rejects with an ExpectedWebSocketRequestRejectionExpectedWebSocketRequestRejection
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 ExceptionHandlerExceptionHandler
Provides a stream of an uploaded file from a multipart request
Provides streams of all uploaded files from a multipart request
Extracts an HTTP form field (of Content-Type application/x-www-form-urlencoded
or multipart/form-data
) from the request
Extracts a number of HTTP form field (of Content-Type application/x-www-form-urlencoded
or multipart/form-data
) from the request as a Map[String, String]
Map<String, String>
Extracts a number of HTTP form field (of Content-Type application/x-www-form-urlencoded
or multipart/form-data
) from the request as a Map[String, List[String]]
Map<String, List<String>>
Extracts a number of HTTP form field (of Content-Type application/x-www-form-urlencoded
or multipart/form-data
) from the request
Extracts a number of HTTP form field (of Content-Type application/x-www-form-urlencoded
or multipart/form-data
) from the request as a Seq[(String, String)]
List<Map.Entry<String, String>>
Rejects all non-GET requests
Serves the content of the given directories as a file-system browser, i.e. files are sent and directories served as browseable listings
Serves the content of the given directory as a file-system browser, i.e. files are sent and directories served as browseable listings
Completes GET requests with the content of a file underneath a given file-system directory
Completes GET requests with the content of a given file
Completes GET requests with the content of a given class-path resource
Completes GET requests with the content of a file underneath a given “class-path resource directory”
Transforms exceptions thrown during evaluation of the inner route using the given ExceptionHandlerExceptionHandler
Transforms rejections produced by the inner route using the given RejectionHandler
Handles websocket requests with the given handler and rejects other requests with an ExpectedWebSocketRequestRejectionExpectedWebSocketRequestRejection
handleWebSocketMessagesForOptionalProtocol
Handles websocket requests with the given handler if the subprotocol matches and rejects other requests. If the subprotocol parameter is None
empty any WebSocket request is accepted..
handleWebSocketMessagesForProtocol
Handles websocket requests with the given handler if the subprotocol matches and rejects other requests with an ExpectedWebSocketRequestRejectionExpectedWebSocketRequestRejection or an UnsupportedWebSocketSubprotocolRejectionUnsupportedWebSocketSubprotocolRejection.
Completes the request using a given function
Rejects all non-HEAD requests
Extracts an HTTP header value using a given HttpHeader => Option[T]
Function<HttpHeader, Optional<T>>
function
Extracts the value of the first HTTP request header with a given name
Extracts the first HTTP request header of the given type
Extracts an HTTP header value using a given PartialFunction[HttpHeader, T]]
PartialFunction<HttpHeader, T>
Rejects all requests with a non-matching host name
Retries the inner route adding (or removing) the trailing slash in case of empty rejections
Validates a JSON Web Token (JWT) from a request and extracts its claims for further processing
Completes GET requests with a unified listing of the contents of all given file-system directories
Produces a log entry for every incoming request
Produces a log entry for every incoming request and RouteResultRouteResult
Produces a log entry for every RouteResultRouteResult
Transforms its inner RouteRoute with a Route => Route
UnaryOperator<Route>
function
Transforms rejections from a previous route with an immutable.Seq[Rejection] => immutable.Seq[Rejection]
UnaryOperator<List<Rejection>>
function
Transforms the request with an HttpRequest => HttpRequest
UnaryOperator<HttpRequest>
function
Transforms the RequestContextRequestContext with a RequestContext => RequestContext
UnaryOperator<RequestContext>
function
Transforms the response with an HttpResponse => HttpResponse
UnaryOperator<HttpResponse>
function
Transforms the response entity with an ResponseEntity => ResponseEntity
UnaryOperator<ResponseEntity>
function
Transforms the response headers with an immutable.Seq[HttpHeader] => immutable.Seq[HttpHeader]
UnaryOperator<List<HttpHeader>>
function
Transforms the RouteResultRouteResult with a RouteResult => RouteResult
UnaryOperator<RouteResult>
function
Transforms the RouteResultRouteResult future with a Future[RouteResult] => Future[RouteResult]
UnaryOperator<CompletionStage<RouteResult>>
function
Transforms the RouteResultRouteResult with a PartialFunction[RouteResult, RouteResult]
PartialFunction<RouteResult, RouteResult>
Transforms the RouteResultRouteResult with a RouteResult => Future[RouteResult]
Function<RouteResult, CompletionStage<RouteResult>>
function
Transforms the RouteResultRouteResult with a PartialFunction[RouteResult, Future[RouteResult]]
PartialFunction<RouteResult, CompletionStage<RouteResult>>
Transforms the RoutingSettingsRoutingSettings with a RoutingSettings => RoutingSettings
UnaryOperator<RoutingSettings>
function
Transforms the unmatchedPath
of the RequestContextRequestContext using a Uri.Path => Uri.Path
UnaryOperator<Uri.Path>
function
Rejects all requests whose HTTP method does not match the given one
“Unwraps” a Future[T]
CompletionStage<T>
and runs the inner route after future completion with the future’s value as an extraction of type Try[T]
Try<T>
“Unwraps” a Future[T]
CompletionStage<T>
inside a CircuitBreakerCircuitBreaker and runs the inner route after future completion with the future’s value as an extraction of type Try[T]
Try<T>
“Unwraps” a Future[T]
CompletionStage<T>
and runs the inner route after future completion with the future’s value as an extraction of type T
Extracts the value of an optional request attribute with a given key
Extracts the HttpCookiePairHttpCookiePair with the given name as an Option[HttpCookiePair]
Optional<HttpCookiePair>
Extracts an optional HTTP header value using a given HttpHeader => Option[T]
Function<HttpHeader, Optional<T>>
function
Extracts the value of the first optional HTTP request header with a given name
Extracts the first optional HTTP request header of the given type
Extracts an optional HTTP header value using a given PartialFunction[HttpHeader, T]
PartialFunction<HttpHeader, T>
Rejects all non-OPTIONS requests
Changes the request method to the value of the specified query parameter
Extracts a query parameter value from the request
Extracts the request’s query parameters as a Map[String, String]
Map<String, String>
Extracts the request’s query parameters as a Map[String, List[String]]
Map<String, List<String>>
Extracts a number of query parameter values from the request
Extracts the request’s query parameters as a Seq[(String, String)]
List<Map.Entry<String, String>>
Always simply passes the request on to its inner route, i.e. doesn’t do anything, neither with the request nor the response
Rejects all non-PATCH requests
Applies the given PathMatcher
to the remaining unmatched path after consuming a leading slash
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
Applies the given PathMatcher
to a prefix of the remaining unmatched path after consuming a leading slash
Checks whether the unmatchedPath has a prefix matched by the given PathMatcher
after implicitly consuming a leading 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 unmatched path (Caution: check scaladocjava!)
Checks whether the unmatched path has a suffix matched by the given PathMatcher
(Caution: check scaladocjava!)
Rejects all non-POST requests
Injects a given value into a directive
Rejects all non-PUT requests
Applies the given matcher directly to a prefix of the unmatched path of the RequestContextRequestContext, without implicitly consuming a leading slash
Checks whether the unmatchedPath has a prefix matched by the given PathMatcher
Transforms rejections from the inner route with an immutable.Seq[Rejection] => RouteResult
Function<List<Rejection>, RouteResult>
function
Transforms rejections from the inner route with an immutable.Seq[Rejection] => Future[RouteResult]
Function<List<Rejection], CompletionStage<RouteResult>>
function
Completes the request with redirection response of the given type to the given URI
redirectToNoTrailingSlashIfPresent
If the request path ends with a slash, redirects to the same URI without trailing slash in the path
redirectToTrailingSlashIfMissing
If the request path doesn’t end with a slash, redirects to the same URI with trailing slash in the path
Rejects the request with the given rejections
Converts responses with an empty entity into (empty) rejections
Rejects the request with an UnsupportedRequestEncodingRejectionUnsupportedRequestEncodingRejection if its encoding doesn’t match the given one
Rejects if the request entity is non-empty
Rejects with a RequestEntityExpectedRejectionRequestEntityExpectedRejection if the request entity is empty
requireClientCertificateIdentity
Reject mTLS requests that does not have a client certificate identity matching a regular expression
Adds a given response header if the response doesn’t already contain a header with the same name
Adds the subset of the given headers to the response which doesn’t already have a header with the respective name present in the response
Unconditionally adds a given header to the outgoing response
Unconditionally adds the given headers to the outgoing response
Rejects the request with an UnacceptedResponseEncodingRejectionUnacceptedResponseEncodingRejection if the given response encoding is not accepted by the client
Rejects all requests whose URI scheme doesn’t match the given one
Inspects the request’s Accept-Language
header and determines, which of a given set of language alternatives is preferred by the client
Adds a Set-Cookie
response header with the given cookies
Streams one uploaded file from a multipart request to a file on disk
Streams all uploaded files from a multipart request to files on disk
Extracts a number of values using a RequestContext => Tuple
function
Injects a given tuple of values into a directive
Checks a given condition before running its inner route
Disables request timeouts for a given route.
Skips request entity size check
Runs its inner route with the given alternative ExecutionContext
Runs its inner route with the given alternative LoggingAdapterLoggingAdapter
Runs its inner route with the given alternative MaterializerMaterializer
withPrecompressedMediaTypeSupport
Adds a Content-Encoding: gzip
response header if the entity’s media-type is precompressed with gzip header
Adds Accept-Ranges: bytes
to responses to GET requests, produces partial responses if the initial request contained a valid Range
header
Configures the request timeouts for a given route.
Prepares the HttpResponseHttpResponse that is emitted if a request timeout is triggered. RequestContext => RequestContext
function
Runs its inner route with the given alternative RoutingSettingsRoutingSettings
Applies request entity size check