extractParserSettings

Signature

def extractParserSettings: Directive1[ParserSettings]

Description

Extracts the request’s underlying ParserSettingsParserSettings, which can be useful when you want to access custom status codes and media types.

Example

Scala
sourceval route =
  extractParserSettings { parserSettings =>
    complete(s"URI parsing mode is ${parserSettings.uriParsingMode}")
  }

// tests:
Get("/") ~> route ~> check {
  responseAs[String] shouldEqual "URI parsing mode is Strict"
}
Java
sourceimport static akka.http.javadsl.server.Directives.extractParserSettings;

final Route route = extractParserSettings(parserSettings ->
  complete("URI parsing mode is " + parserSettings.getUriParsingMode())
);

// tests:
testRoute(route).run(HttpRequest.GET("/"))
  .assertEntity("URI parsing mode is Strict");
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.