Predefined Directives (alphabetically)
Loading

Predefined Directives (alphabetically)

Directive Description
-cancelAllRejections- Adds a TransformationRejection to rejections from its inner Route, which cancels other rejections according to a predicate function
-cancelRejection- Adds a TransformationRejection cancelling all rejections equal to a given one
-clientIP- Extracts the IP address of the client from either the X-Forwarded-For, Remote-Address or X-Real-IP request header
-complete- Completes the request with a given response, several overloads
compressResponse Compresses responses coming back from its inner Route using either Gzip or Deflate unless the request explicitly sets Accept-Encoding to identity.
compressResponseIfRequested Compresses responses coming back from its inner Route using either Gzip or Deflate, but only when the request explicitly accepts one of them.
-conditional- Depending on the given ETag and Last-Modified values responds with 304 Not Modified if the request comes with the respective conditional headers.
cookie Extracts an HttpCookie with a given name or rejects if no such cookie is present in the request
decodeRequest Decompresses incoming requests using a given Decoder
decompressRequest Decompresses incoming requests using either Gzip, Deflate, or NoEncoding
-delete- Rejects all non-DELETE requests
deleteCookie Adds a Set-Cookie header expiring the given cookie to all HttpResponse replies of its inner Route
encodeResponse Compresses responses coming back from its inner Route using a given Encoder
-entity- Unmarshalls the requests entity according to a given definition, rejects in case of problems
extract Extracts a single value from the RequestContext using a function RequestContext => T
-extractRequest- Extracts the complete request
-failWith- Bubbles the given error up the response chain, where it is dealt with by the closest handleExceptions directive and its ExceptionHandler
-formField- Extracts the value of an HTTP form field, rejects if the request doesn't come with a field matching the definition
-formFields- Same as -formField-, except for several fields at once
-get- Rejects all non-GET requests
getFromBrowseableDirectories Same as getFromBrowseableDirectory, but allows for serving the "union" of several directories as one single "virtual" one
getFromBrowseableDirectory Completes GET requests with the content of a file underneath a given directory, renders directory contents as browsable listings
getFromDirectory Completes GET requests with the content of a file underneath a given directory
getFromFile Completes GET requests with the content of a given file
getFromResource Completes GET requests with the content of a given resource
getFromResourceDirectory Same as getFromDirectory except that the file is not fetched from the file system but rather from a "resource directory"
handleExceptions Converts exceptions thrown during evaluation of its inner Route into HttpResponse replies using a given ExceptionHandler
handleRejections Converts rejections produced by its inner Route into HttpResponse replies using a given RejectionHandler
-handleWith- Completes the request using a given function. Uses the in-scope Unmarshaller and Marshaller for converting to and from the function
-head- Rejects all non-HEAD requests
-headerValue- Extracts an HTTP header value using a given function, rejects if no value can be extracted
-headerValueByName- Extracts an HTTP header value by selecting a header by name
-headerValueByType- Extracts an HTTP header value by selecting a header by type
-headerValuePF- Same as -headerValue-, but with a PartialFunction
-host- Rejects all requests with a hostname different from a given definition, can extract the hostname using a regex pattern
-hostName- Extracts the hostname part of the requests Host header value
listDirectoryContents Completes GET requests with a unified listing of the contents of one or more given directories
logRequest Produces a log entry for every incoming request
logRequestResult Produces a log entry for every response or rejection coming back from its inner route, allowing for coalescing with the corresponding request
logResult Produces a log entry for every response or rejection coming back from its inner route
mapResponse Transforms the HttpResponse coming back from its inner Route
mapResponseEntity Transforms the entity of the HttpResponse coming back from its inner Route
mapResponseHeaders Transforms the headers of the HttpResponse coming back from its inner Route
mapInnerRoute Transforms its inner Route with a Route => Route function
mapRejections Transforms all rejections coming back from its inner Route
mapRequest Transforms the incoming HttpRequest
mapRequestContext Transforms the RequestContext
mapRouteResult Transforms all responses coming back from its inner Route with a Any => Any function
-mapRouteResultPF- Same as mapRouteResult, but with a PartialFunction
-method- Rejects if the request method does not match a given one
-overrideMethodWithParameter- Changes the HTTP method of the request to the value of the specified query string parameter
-onComplete- "Unwraps" a Future[T] and runs its inner route after future completion with the future's value as an extraction of type Try[T]
-onFailure- "Unwraps" a Future[T] and runs its inner route when the future has failed with the future's failure exception as an extraction of type Throwable
-onSuccess- "Unwraps" a Future[T] and runs its inner route after future completion with the future's value as an extraction of type T
optionalCookie Extracts an HttpCookie with a given name, if the cookie is not present in the request extracts None
-optionalHeaderValue- Extracts an optional HTTP header value using a given function
-optionalHeaderValueByName- Extracts an optional HTTP header value by selecting a header by name
-optionalHeaderValueByType- Extracts an optional HTTP header value by selecting a header by type
-optionalHeaderValuePF- Extracts an optional HTTP header value using a given partial function
-options- Rejects all non-OPTIONS requests
-parameter- Extracts the value of a request query parameter, rejects if the request doesn't come with a parameter matching the definition
-parameterMap- Extracts the requests query parameters as a Map[String, String]
-parameterMultiMap- Extracts the requests query parameters as a Map[String, List[String]]
-parameters- Same as -parameter-, except for several parameters at once
-parameterSeq- Extracts the requests query parameters as a Seq[(String, String)]
pass Does nothing, i.e. passes the RequestContext unchanged to its inner Route
-patch- Rejects all non-PATCH requests
path Extracts zero+ values from the unmatchedPath of the RequestContext according to a given PathMatcher, rejects if no match
pathEnd Only passes on the request to its inner route if the request path has been matched completely, rejects otherwise
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, rejects otherwise
pathPrefix Same as path, but also matches (and consumes) prefixes of the unmatched path (rather than only the complete unmatched path at once)
pathPrefixTest Like pathPrefix but without "consumption" of the matched path (prefix).
pathSingleSlash Only passes on the request to its inner route if the request path consists of exactly one remaining slash
pathSuffix Like as pathPrefix, but for suffixes rather than prefixed of the unmatched path
pathSuffixTest Like pathSuffix but without "consumption" of the matched path (suffix).
-post- Rejects all non-POST requests
-produce- Uses the in-scope marshaller to extract a function that can be used for completing the request with an instance of a custom type
provide Injects a single value into a directive, which provides it as an extraction
-put- Rejects all non-PUT requests
rawPathPrefix Applies a given PathMatcher directly to the unmatched path of the RequestContext, i.e. without implicitly consuming a leading slash
rawPathPrefixTest Checks whether the unmatchedPath of the RequestContext has a prefix matched by a PathMatcher
-redirect- Completes the request with redirection response of the given type to a given URI
-reject- Rejects the request with a given set of rejections
-rejectEmptyResponse- Converts responses with an empty entity into a rejection
requestEncodedWith Rejects the request if its encoding doesn't match a given one
-requestEntityEmpty- Rejects the request if its entity is not empty
-requestEntityPresent- Rejects the request if its entity is empty
-requestUri- Extracts the complete request URI
-respondWithHeader- Adds a given response header to all HttpResponse replies from its inner Route
-respondWithHeaders- Same as -respondWithHeader-, but for several headers at once
-respondWithMediaType- Overrides the media-type of all HttpResponse replies from its inner Route, rejects if the media-type is not accepted by the client
-respondWithSingletonHeader- Adds a given response header to all HttpResponse replies from its inner Route, if a header with the same name is not yet present
-respondWithSingletonHeaders- Same as -respondWithSingletonHeader-, but for several headers at once
-respondWithStatus- Overrides the response status of all HttpResponse replies coming back from its inner Route
responseEncodingAccepted Rejects the request if the client doesn't accept a given encoding for the response
-mapUnmatchedPath- Transforms the unmatchedPath of the RequestContext using a given function
-scheme- Rejects a request if its Uri scheme does not match a given one
-schemeName- Extracts the request Uri scheme
setCookie Adds a Set-Cookie header to all HttpResponse replies of its inner Route
textract Extracts a TupleN of values from the RequestContext using a function
-hprovide- Injects a TupleN of values into a directive, which provides them as extractions
-unmatchedPath- Extracts the unmatched path from the RequestContext
-validate- Passes or rejects the request depending on evaluation of a given conditional expression
-withRangeSupport- Transforms the response from its inner route into a 206 Partial Content response if the client requested only part of the resource with a Range header.

Contents