Interface HeaderDirectives
-
- All Known Subinterfaces:
Directives
- All Known Implementing Classes:
Directives$
,HeaderDirectives$
,HttpApp
public interface HeaderDirectives
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description Directive<scala.runtime.BoxedUnit>
checkSameOrigin(HttpOriginRange.Default allowed)
Checks that request comes from the same origin.<T> Directive<scala.Tuple1<T>>
headerValue(scala.Function1<HttpHeader,scala.Option<T>> f)
Extracts an HTTP header value using the given function.Directive<scala.Tuple1<java.lang.String>>
headerValueByName(java.lang.String headerName)
Extracts the value of the HTTP request header with the given name.Directive<scala.Tuple1<java.lang.String>>
headerValueByName(scala.Symbol headerName)
Deprecated.Use string argument version or `headerValueByType`, e.g. instead of `headerValueByName('Referer)` use `headerValueByType(Referer)`.<T> Directive<scala.Tuple1<T>>
headerValueByType(HeaderMagnet<T> magnet)
Extracts the first HTTP request header of the given type.<T> Directive<scala.Tuple1<T>>
headerValuePF(scala.PartialFunction<HttpHeader,T> pf)
Extracts an HTTP header value using the given partial function.<T> Directive<scala.Tuple1<scala.Option<T>>>
optionalHeaderValue(scala.Function1<HttpHeader,scala.Option<T>> f)
Extracts an optional HTTP header value using the given function.Directive<scala.Tuple1<scala.Option<java.lang.String>>>
optionalHeaderValueByName(java.lang.String headerName)
Extracts the value of the optional HTTP request header with the given name.Directive<scala.Tuple1<scala.Option<java.lang.String>>>
optionalHeaderValueByName(scala.Symbol headerName)
Deprecated.Use string argument version or `headerValueByType`, e.g. instead of `optionalHeaderValueByName('Referer)` use `optionalHeaderValueByType(Referer)`.<T extends HttpHeader>
Directive<scala.Tuple1<scala.Option<T>>>optionalHeaderValueByType(HeaderMagnet<T> magnet)
Extract the header value of the optional HTTP request header with the given type.<T> Directive<scala.Tuple1<scala.Option<T>>>
optionalHeaderValuePF(scala.PartialFunction<HttpHeader,T> pf)
Extracts an optional HTTP header value using the given partial function.scala.Function1<HttpHeader,scala.Option<java.lang.String>>
optionalValue(java.lang.String lowerCaseName)
-
-
-
Method Detail
-
checkSameOrigin
Directive<scala.runtime.BoxedUnit> checkSameOrigin(HttpOriginRange.Default allowed)
Checks that request comes from the same origin. Extracts theOrigin
header value and verifies that allowed range contains the obtained value. In the case of absent of theOrigin
header rejects withMissingHeaderRejection
. If the origin value is not in the allowed range rejects with anInvalidOriginRejection
andStatusCodes.Forbidden
status.- Parameters:
allowed
- (undocumented)- Returns:
- (undocumented)
-
headerValue
<T> Directive<scala.Tuple1<T>> headerValue(scala.Function1<HttpHeader,scala.Option<T>> f)
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)- Returns:
- (undocumented)
-
headerValuePF
<T> Directive<scala.Tuple1<T>> headerValuePF(scala.PartialFunction<HttpHeader,T> pf)
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)- Returns:
- (undocumented)
-
headerValueByName
Directive<scala.Tuple1<java.lang.String>> headerValueByName(scala.Symbol headerName)
Deprecated.Use string argument version or `headerValueByType`, e.g. instead of `headerValueByName('Referer)` use `headerValueByType(Referer)`. Since 10.2.0.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)- Returns:
- (undocumented)
-
headerValueByName
Directive<scala.Tuple1<java.lang.String>> headerValueByName(java.lang.String headerName)
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 aMissingHeaderRejection
.- Parameters:
headerName
- (undocumented)- Returns:
- (undocumented)
-
headerValueByType
<T> Directive<scala.Tuple1<T>> headerValueByType(HeaderMagnet<T> magnet)
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
.Custom headers will only be matched by this directive if they extend
ModeledCustomHeader
and provide a companion extendingModeledCustomHeaderCompanion
.- Parameters:
magnet
- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValue
<T> Directive<scala.Tuple1<scala.Option<T>>> optionalHeaderValue(scala.Function1<HttpHeader,scala.Option<T>> f)
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)- Returns:
- (undocumented)
-
optionalHeaderValuePF
<T> Directive<scala.Tuple1<scala.Option<T>>> optionalHeaderValuePF(scala.PartialFunction<HttpHeader,T> pf)
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)- Returns:
- (undocumented)
-
optionalHeaderValueByName
Directive<scala.Tuple1<scala.Option<java.lang.String>>> optionalHeaderValueByName(scala.Symbol headerName)
Deprecated.Use string argument version or `headerValueByType`, e.g. instead of `optionalHeaderValueByName('Referer)` use `optionalHeaderValueByType(Referer)`. Since 10.2.0.Extracts the value of the optional HTTP request header with the given name.- Parameters:
headerName
- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValueByName
Directive<scala.Tuple1<scala.Option<java.lang.String>>> optionalHeaderValueByName(java.lang.String headerName)
Extracts the value of the optional HTTP request header with the given name.- Parameters:
headerName
- (undocumented)- Returns:
- (undocumented)
-
optionalHeaderValueByType
<T extends HttpHeader> Directive<scala.Tuple1<scala.Option<T>>> optionalHeaderValueByType(HeaderMagnet<T> magnet)
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 extendingModeledCustomHeaderCompanion
.- Parameters:
magnet
- (undocumented)- Returns:
- (undocumented)
-
optionalValue
scala.Function1<HttpHeader,scala.Option<java.lang.String>> optionalValue(java.lang.String lowerCaseName)
-
-