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 org.apache.pekko.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");