Class HeaderDirectives
- java.lang.Object
-
- akka.http.javadsl.server.directives.BasicDirectives
-
- akka.http.javadsl.server.directives.CacheConditionDirectives
-
- akka.http.javadsl.server.directives.CodingDirectives
-
- akka.http.javadsl.server.directives.CookieDirectives
-
- akka.http.javadsl.server.directives.DebuggingDirectives
-
- akka.http.javadsl.server.directives.ExecutionDirectives
-
- akka.http.javadsl.server.directives.FileAndResourceDirectives
-
- akka.http.javadsl.server.directives.FileUploadDirectives
-
- akka.http.javadsl.server.directives.FormFieldDirectives
-
- akka.http.javadsl.server.directives.FutureDirectives
-
- akka.http.javadsl.server.directives.HeaderDirectives
-
- Direct Known Subclasses:
AttributeDirectives
public abstract class HeaderDirectives extends FutureDirectives
-
-
Constructor Summary
Constructors Constructor Description HeaderDirectives()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RoutecheckSameOrigin(HttpOriginRange allowed, java.util.function.Supplier<Route> inner)Checks that request comes from the same origin.<T> RouteAdapterheaderValue(java.util.function.Function<HttpHeader,java.util.Optional<T>> f, java.util.function.Function<T,Route> inner)Extracts an HTTP header value using the given function.RouteAdapterheaderValueByName(java.lang.String headerName, java.util.function.Function<java.lang.String,Route> inner)Extracts the value of the first HTTP request header with the given name.<T extends HttpHeader>
RouteAdapterheaderValueByType(java.lang.Class<T> t, java.util.function.Function<T,Route> inner)Extracts the first HTTP request header of the given type.<T> RouteAdapterheaderValuePF(scala.PartialFunction<HttpHeader,T> pf, java.util.function.Function<T,Route> inner)Extracts an HTTP header value using the given partial function.<T> RouteAdapteroptionalHeaderValue(java.util.function.Function<HttpHeader,java.util.Optional<T>> f, java.util.function.Function<java.util.Optional<T>,Route> inner)Extracts an optional HTTP header value using the given function.RouteAdapteroptionalHeaderValueByName(java.lang.String headerName, java.util.function.Function<java.util.Optional<java.lang.String>,Route> inner)Extracts the value of the optional HTTP request header with the given name.<T extends HttpHeader>
RouteAdapteroptionalHeaderValueByType(java.lang.Class<T> t, java.util.function.Function<java.util.Optional<T>,Route> inner)FIXME: WARNING: Custom headers don't work yet with this directive!<T> RouteAdapteroptionalHeaderValuePF(scala.PartialFunction<HttpHeader,T> pf, java.util.function.Function<java.util.Optional<T>,Route> inner)Extracts an optional HTTP header value using the given partial function.-
Methods inherited from class akka.http.javadsl.server.directives.FutureDirectives
completeOrRecoverWith, onComplete, onComplete, onCompleteWithBreaker, onSuccess, onSuccess
-
Methods inherited from class akka.http.javadsl.server.directives.FormFieldDirectives
formField, formField, formFieldList, formFieldList, formFieldList, formFieldMap, formFieldMultiMap, formFieldOptional, formFieldOptional
-
Methods inherited from class akka.http.javadsl.server.directives.FileUploadDirectives
fileUpload, fileUploadAll, storeUploadedFile, storeUploadedFiles
-
Methods inherited from class akka.http.javadsl.server.directives.FileAndResourceDirectives
defaultContentTypeResolver, defaultDirectoryRenderer, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectory, getFromBrowseableDirectory, getFromBrowseableDirectory, getFromBrowseableDirectory, getFromDirectory, getFromDirectory, getFromFile, getFromFile, getFromFile, getFromFile, getFromFile, getFromResource, getFromResource, getFromResource, getFromResource, getFromResourceDirectory, getFromResourceDirectory, getFromResourceDirectory, getFromResourceDirectory, listDirectoryContents, listDirectoryContents, listDirectoryContents, listDirectoryContents
-
Methods inherited from class akka.http.javadsl.server.directives.ExecutionDirectives
handleExceptions, handleRejections
-
Methods inherited from class akka.http.javadsl.server.directives.DebuggingDirectives
logRequest, logRequest, logRequest, logRequestResult, logRequestResultOptional, logResult, logResult, logResult
-
Methods inherited from class akka.http.javadsl.server.directives.CookieDirectives
cookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, optionalCookie, setCookie, setCookie
-
Methods inherited from class akka.http.javadsl.server.directives.CodingDirectives
decodeRequest, decodeRequestWith, decodeRequestWith, encodeResponse, encodeResponseWith, requestEncodedWith, responseEncodingAccepted, withPrecompressedMediaTypeSupport
-
Methods inherited from class akka.http.javadsl.server.directives.CacheConditionDirectives
conditional, conditional, conditional, conditional
-
Methods inherited from class akka.http.javadsl.server.directives.BasicDirectives
cancelRejection, cancelRejections, cancelRejections, extract, extractActorSystem, extractDataBytes, extractEntity, extractExecutionContext, extractLog, extractMatchedPath, extractMaterializer, extractParserSettings, extractRequest, extractRequestContext, extractRequestEntity, extractSettings, extractStrictEntity, extractStrictEntity, extractUnmatchedPath, extractUri, mapInnerRoute, mapRejections, mapRequest, mapRequestContext, mapResponse, mapResponseEntity, mapResponseHeaders, mapRouteResult, mapRouteResultFuture, mapRouteResultPF, mapRouteResultWith, mapRouteResultWithPF, mapSettings, mapUnmatchedPath, pass, provide, recoverRejections, recoverRejectionsWith, toStrictEntity, toStrictEntity, withExecutionContext, withLog, withMaterializer, withSettings
-
-
-
-
Method Detail
-
checkSameOrigin
public Route checkSameOrigin(HttpOriginRange allowed, java.util.function.Supplier<Route> inner)
Checks that request comes from the same origin. Extracts theOriginheader value and verifies that allowed range contains the obtained value. In the case of absent of theOriginheader rejects withMissingHeaderRejection. If the origin value is not in the allowed range rejects with anInvalidOriginRejectionandStatusCodes.FORBIDDENstatus.- Parameters:
allowed- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
headerValue
public <T> RouteAdapter headerValue(java.util.function.Function<HttpHeader,java.util.Optional<T>> f, java.util.function.Function<T,Route> inner)
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 aMalformedHeaderRejection.- Parameters:
f- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
headerValueByName
public RouteAdapter headerValueByName(java.lang.String headerName, java.util.function.Function<java.lang.String,Route> inner)
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 aMissingHeaderRejection.- Parameters:
headerName- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
headerValueByType
public <T extends HttpHeader> RouteAdapter headerValueByType(java.lang.Class<T> t, java.util.function.Function<T,Route> inner)
Extracts the first HTTP request header of the given type. If no header with a matching type is found the request is rejected with aMissingHeaderRejection.- Parameters:
t- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
headerValuePF
public <T> RouteAdapter headerValuePF(scala.PartialFunction<HttpHeader,T> pf, java.util.function.Function<T,Route> inner)
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.- Parameters:
pf- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValue
public <T> RouteAdapter optionalHeaderValue(java.util.function.Function<HttpHeader,java.util.Optional<T>> f, java.util.function.Function<java.util.Optional<T>,Route> inner)
Extracts an optional HTTP header value using the given function. If the given function throws an exception the request is rejected with aMalformedHeaderRejection.- Parameters:
f- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValueByName
public RouteAdapter optionalHeaderValueByName(java.lang.String headerName, java.util.function.Function<java.util.Optional<java.lang.String>,Route> inner)
Extracts the value of the optional HTTP request header with the given name.- Parameters:
headerName- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValueByType
public <T extends HttpHeader> RouteAdapter optionalHeaderValueByType(java.lang.Class<T> t, java.util.function.Function<java.util.Optional<T>,Route> inner)
FIXME: WARNING: Custom headers don't work yet with this directive!Extract the header value of the optional HTTP request header with the given type.
- Parameters:
t- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValuePF
public <T> RouteAdapter optionalHeaderValuePF(scala.PartialFunction<HttpHeader,T> pf, java.util.function.Function<java.util.Optional<T>,Route> inner)
Extracts an optional HTTP header value using the given partial function. If the given function throws an exception the request is rejected with aMalformedHeaderRejection.- Parameters:
pf- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
-