requestEntityPresent

requestEntityPresent

Signature

Description

A simple filter that checks if the request entity is present and only then passes processing to the inner route. Otherwise, the request is rejected.

See also requestEntityEmpty for the opposite effect.

Example

val route =
  requestEntityEmpty {
    complete("request entity empty")
  } ~
    requestEntityPresent {
      complete("request entity present")
    }

// tests:
Post("/", "text") ~> Route.seal(route) ~> check {
  responseAs[String] shouldEqual "request entity present"
}
Post("/") ~> route ~> check {
  responseAs[String] shouldEqual "request entity empty"
}

Contents