Class HeaderDirectives

Direct Known Subclasses:
AttributeDirectives

public abstract class HeaderDirectives extends FutureDirectives
  • Constructor Details

    • HeaderDirectives

      public HeaderDirectives()
  • Method Details

    • checkSameOrigin

      public Route checkSameOrigin(HttpOriginRange allowed, 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(Function<HttpHeader,Optional<T>> f, 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(String headerName, Function<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 HttpHeader> RouteAdapter headerValueByType(Class<T> t, 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, 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(Function<HttpHeader,Optional<T>> f, Function<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(String headerName, Function<Optional<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(Class<T> t, Function<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, Function<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)