MiscDirectives

org.apache.pekko.http.scaladsl.server.directives.MiscDirectives
See theMiscDirectives companion trait

Attributes

Companion
trait
Source
MiscDirectives.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Grouped members

misc

Extracts the client's IP from either the X-Forwarded-For, Remote-Address, X-Real-IP header or pekko.http.scaladsl.model.AttributeKeys.remoteAddress attribute (in that order of priority).

Extracts the client's IP from either the X-Forwarded-For, Remote-Address, X-Real-IP header or pekko.http.scaladsl.model.AttributeKeys.remoteAddress attribute (in that order of priority).

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala

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.

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.

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala

Rejects if the request entity is non-empty.

Rejects if the request entity is non-empty.

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala

Rejects with a RequestEntityExpectedRejection if the request entity is empty. Non-empty requests are passed on unchanged to the inner route.

Rejects with a RequestEntityExpectedRejection if the request entity is empty. Non-empty requests are passed on unchanged to the inner route.

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala

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).

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).

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala
def validate(check: => Boolean, errorMsg: String): Directive0

Checks the given condition before running its inner route. If the condition fails the route is rejected with a ValidationRejection.

Checks the given condition before running its inner route. If the condition fails the route is rejected with a ValidationRejection.

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala
def withSizeLimit(maxBytes: Long): Directive0

Fails the stream with pekko.http.scaladsl.model.EntityStreamSizeException if its request entity size exceeds given limit. Limit given as parameter overrides limit configured with pekko.http.parsing.max-content-length.

Fails the stream with pekko.http.scaladsl.model.EntityStreamSizeException if its request entity size exceeds given limit. Limit given as parameter overrides limit configured with pekko.http.parsing.max-content-length.

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

Attributes

Inherited from:
MiscDirectives
Source
MiscDirectives.scala

Disables the size limit (configured by pekko.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.

Disables the size limit (configured by pekko.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.

Attributes

Note

Usage of withoutSizeLimit is not recommended as it turns off the too large payload protection. Therefore, we highly encourage using withSizeLimit instead, providing it with a value high enough to successfully handle the route in need of big entities.

Inherited from:
MiscDirectives
Source
MiscDirectives.scala