extractRequestEntity

extractRequestEntity

Signature

Description

Extracts the RequestEntity from the RequestContext.

The directive returns a RequestEntity without unmarshalling the request. To extract domain entity, entity should be used.

Example

val route =
  extractRequestEntity { entity =>
    complete(s"Request entity content-type is ${entity.contentType}")
  }

// tests:
val httpEntity = HttpEntity(ContentTypes.`text/plain(UTF-8)`, "req")
Post("/abc", httpEntity) ~> route ~> check {
  responseAs[String] shouldEqual "Request entity content-type is text/plain; charset=UTF-8"
}

Contents