extractHost

extractHost

Signature

Description

Extract the hostname part of the Host request header and expose it as a String extraction to its inner route.

Example

val route =
  extractHost { hn =>
    complete(s"Hostname: $hn")
  }

// tests:
Get() ~> Host("company.com", 9090) ~> route ~> check {
  status shouldEqual OK
  responseAs[String] shouldEqual "Hostname: company.com"
}

Contents