Calculates an HList of values from the request context and provides them to the inner route.


def hextract[L <: HList](f: RequestContext  L): Directive[L] 


The hextract 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 hprovide directive instead.

See Directives to provide values to inner routes for an overview of similar directives.


import shapeless.HNil
val pathAndQuery = hextract { ctx =>
  val uri = ctx.request.uri
  uri.path :: uri.query :: HNil
val route =
  pathAndQuery { (p, query) =>
    complete(s"The path is $p and the query is $query")

Get("/abcdef?ghi=12") ~> route ~> check {
  responseAs[String] === "The path is /abcdef and the query is ghi=12"