mapSettings
Description
Transforms the RoutingSettings
RoutingSettings
with a RoutingSettings => RoutingSettings
functionFunction<RoutingSettings, RoutingSettings>
.
See also withSettings or extractSettings.
Example
- Scala
-
source
val tunedSettings = mapSettings { settings => settings.withFileGetConditional(false) } val route = tunedSettings { extractSettings { (settings: RoutingSettings) => complete(s"RoutingSettings.fileGetConditional = ${settings.fileGetConditional}") } } // tests: Get("/") ~> route ~> check { responseAs[String] shouldEqual s"RoutingSettings.fileGetConditional = false" }
- Java
-
source
import static akka.http.javadsl.server.Directives.mapSettings; final Route route = mapSettings(settings -> settings.withFileGetConditional(false), () -> extractSettings(settings -> complete("RoutingSettings.fileGetConditional = " + settings.getFileGetConditional()) ) ); // tests: testRoute(route).run(HttpRequest.GET("/")) .assertEntity("RoutingSettings.fileGetConditional = false");