Class MiscDirectives

Direct Known Subclasses:
ParameterDirectives

public abstract class MiscDirectives extends MethodDirectives
  • Constructor Details

    • MiscDirectives

      public MiscDirectives()
  • Method Details

    • extractClientIP

      public Route extractClientIP(Function<RemoteAddress,Route> inner)
      Extracts the client's IP from either the X-Forwarded-For, Remote-Address, X-Real-IP header or akka.http.javadsl.model.AttributeKeys.remoteAddress attribute (in that order of priority).
      Parameters:
      inner - (undocumented)
      Returns:
      (undocumented)
    • rejectEmptyResponse

      public Route rejectEmptyResponse(Supplier<Route> inner)
      Converts responses with an empty entity into (empty) rejections. This way you can, for example, have the marshalling of a ''None'' option be treated as if the request could not be matched.
      Parameters:
      inner - (undocumented)
      Returns:
      (undocumented)
    • requestEntityEmpty

      public Route requestEntityEmpty(Supplier<Route> inner)
      Rejects if the request entity is non-empty.
      Parameters:
      inner - (undocumented)
      Returns:
      (undocumented)
    • requestEntityPresent

      public Route requestEntityPresent(Supplier<Route> inner)
      Rejects with a RequestEntityExpectedRejection if the request entity is empty. Non-empty requests are passed on unchanged to the inner route.
      Parameters:
      inner - (undocumented)
      Returns:
      (undocumented)
    • selectPreferredLanguage

      public Route selectPreferredLanguage(Iterable<Language> languages, Function<Language,Route> inner)
      Inspects the request's Accept-Language header and determines, which of the given language alternatives is preferred by the client. (See http://tools.ietf.org/html/rfc7231#section-5.3.5 for more details on the negotiation logic.) If there are several best language alternatives that the client has equal preference for (even if this preference is zero!) the order of the arguments is used as a tie breaker (First one wins).

      If [languages] is empty, the route is rejected.

      Parameters:
      languages - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)
    • validate

      public Route validate(BooleanSupplier check, String errorMsg, Supplier<Route> inner)
      Checks the given condition before running its inner route. If the condition fails the route is rejected with a ValidationRejection.
      Parameters:
      check - (undocumented)
      errorMsg - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)
    • withSizeLimit

      public Route withSizeLimit(long maxBytes, Supplier<Route> inner)
      Fails the stream with EntityStreamSizeException if its request entity size exceeds given limit. Limit given as parameter overrides limit configured with akka.http.parsing.max-content-length.

      Beware that request entity size check is executed when entity is consumed.

      Parameters:
      maxBytes - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)
    • withoutSizeLimit

      public Route withoutSizeLimit(Supplier<Route> inner)
      Disables the size limit (configured by akka.http.parsing.max-content-length by default) checking on the incoming HttpRequest entity. Can be useful when handling arbitrarily large data uploads in specific parts of your routes.

      Parameters:
      inner - (undocumented)
      Returns:
      (undocumented)