requestInstance
Extracts the complete HttpRequest instance.
Signature
def requestInstance: Directive1[HttpRequest]
Description
Use requestUri to extract just the complete URI of the request. Usually there’s little use of extracting the complete request because extracting of most of the aspects of HttpRequests is handled by specialized directives. See Directives filtering or extracting from the request.
Example
val route =
requestInstance { request =>
complete(s"Request method is ${request.method} and length is ${request.entity.data.length}")
}
Post("/", "text") ~> route ~> check {
responseAs[String] === "Request method is POST and length is 4"
}
Get("/") ~> route ~> check {
responseAs[String] === "Request method is GET and length is 0"
}