extractScheme

Signature

def extractScheme: Directive1[String]

Description

Extracts the Uri scheme (i.e. “http”, “https”, etc.) for an incoming request.

For rejecting a request if it doesn’t match a specified scheme name, see the scheme directive.

Example

val route =
  extractScheme { scheme =>
    complete(s"The scheme is '${scheme}'")
  }

// tests:
Get("https://www.example.com/") ~> route ~> check {
  responseAs[String] shouldEqual "The scheme is 'https'"
}
The source code for this page can be found here.