textract • Akka HTTP (original) (raw)
The textract
directive is not available in the Java API.
Signature
def textract[L: Tuple](f: RequestContext => L): Directive[L]
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 RequestContextRequestContext and provide it to the inner route. To extract just one value use the extract directive. To provide a constant value independent of the RequestContextRequestContext 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
source`val pathAndQuery = textract { ctx => val uri = ctx.request.uri (uri.path, uri.query()) } val route = pathAndQuery { (p, query) => complete(s"The path is pandthequeryisp and the query is pandthequeryisquery") }
// tests: Get("/abcdef?ghi=12") ~> route ~> check { responseAs[String] shouldEqual "The path is /abcdef and the query is ghi=12" }`
Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.