provide
Description
Provides a constant value to the inner route.
The provide directive is used as a building block for Custom Directives to provide a single value to the inner route. To provide several values use the tprovide directive.
See Providing Values to Inner Routes for an overview of similar directives.
Example
- Scala
-
source
def providePrefixedString(value: String): Directive1[String] = provide("prefix:" + value) val route = providePrefixedString("test") { value => complete(value) } // tests: Get("/") ~> route ~> check { responseAs[String] shouldEqual "prefix:test" }
- Java
-
source
import static org.apache.pekko.http.javadsl.server.Directives.provide; final Route route = providePrefixedStringRoute("test"); // tests: testRoute(route).run(HttpRequest.GET("/")).assertEntity("prefix:test");
1.1.0+17-3b5f9b27*