requestEntityEmpty
A filter that checks if the request entity is empty and only then passes processing to the inner route. Otherwise, the request is rejected.
Signature
def requestEntityEmpty: Directive0
Description
The opposite filter is available as requestEntityPresent.
Example
val route =
requestEntityEmpty {
complete("request entity empty")
} ~
requestEntityPresent {
complete("request entity present")
}
Post("/", "text") ~> sealRoute(route) ~> check {
responseAs[String] === "request entity present"
}
Post("/") ~> route ~> check {
responseAs[String] === "request entity empty"
}