hprovide

Provides an HList of values to the inner route.

Signature

def hprovide[L <: HList](values: L): Directive[L] 

Description

The hprovide directive is used as a building block for Custom Directives to provide data to the inner route. To provide just one value use the provide directive. If you want to provide values calculated from the RequestContext use the hextract directive instead.

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

Example

import shapeless.HNil
def provideStringAndLength(value: String) = hprovide(value :: value.length :: HNil)
val route =
  provideStringAndLength("test") { (value, len) =>
    complete(s"Value is $value and its length is $len")
  }
Get("/") ~> route ~> check {
  responseAs[String] === "Value is test and its length is 4"
}