Class HeaderDirectives

    • Constructor Detail

      • HeaderDirectives

        public HeaderDirectives()
    • Method Detail

      • checkSameOrigin

        public Route checkSameOrigin​(HttpOriginRange allowed,
                                     java.util.function.Supplier<Route> inner)
        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)
        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 a MalformedHeaderRejection.
        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 a MissingHeaderRejection.
        Parameters:
        headerName - (undocumented)
        inner - (undocumented)
        Returns:
        (undocumented)
      • headerValueByType

        public <T extends HttpHeaderRouteAdapter 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 a MissingHeaderRejection.
        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 a MalformedHeaderRejection.
        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 HttpHeaderRouteAdapter 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 a MalformedHeaderRejection.
        Parameters:
        pf - (undocumented)
        inner - (undocumented)
        Returns:
        (undocumented)