textract
Signature
Description
Extracts a tuple of values from the request context and provides them to the inner route.
The textract
directive is used as a building block for Custom Directives to extract data from the
RequestContext
and provide it to the inner route. To extract just one value use the extract directive. To
provide a constant value independent of the RequestContext
use the tprovide directive instead.
See Providing Values to Inner Routes for an overview of similar directives.
See also extract for extracting a single value.
Example
val pathAndQuery = textract { ctx =>
val uri = ctx.request.uri
(uri.path, uri.query())
}
val route =
pathAndQuery { (p, query) =>
complete(s"The path is $p and the query is $query")
}
// tests:
Get("/abcdef?ghi=12") ~> route ~> check {
responseAs[String] shouldEqual "The path is /abcdef and the query is ghi=12"
}
Contents