Interface HeaderDirectives

    • Method Detail

      • checkSameOrigin

        Directive<scala.runtime.BoxedUnit> checkSameOrigin​(HttpOriginRange.Default allowed)
        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.

        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 a MalformedHeaderRejection.

        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 a MissingHeaderRejection.

        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 a MissingHeaderRejection.

        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 a MissingHeaderRejection.

        Custom headers will only be matched by this directive if they extend ModeledCustomHeader and provide a companion extending ModeledCustomHeaderCompanion.

        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 a MalformedHeaderRejection.

        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 a MalformedHeaderRejection.

        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 HttpHeaderDirective<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 extending ModeledCustomHeaderCompanion.

        Parameters:
        magnet - (undocumented)
        Returns:
        (undocumented)
      • optionalValue

        scala.Function1<HttpHeader,​scala.Option<java.lang.String>> optionalValue​(java.lang.String lowerCaseName)