schemeName

Extracts the value of the request Uri scheme.

Signature

def schemeName: Directive1[String] 

Description

The schemeName directive can be used to determine 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 =
  schemeName { scheme =>
    complete(s"The scheme is '${scheme}'")
  }

Get("https://www.example.com/") ~> route ~> check {
  responseAs[String] === "The scheme is 'https'"
}