Skip to content
Search

Akka:Http:ParameterDirectives

lastmod 2026-11-10created 2020-09-213 edits

ParameterDirectives is a set of directives in the Akka HTTP routing DSL that extract URL query parameters. When you specify parameter names with parameter and parameters, their values are passed to the inner route; after the name, .as[Int] expresses type conversion, .? an optional parameter, ? default a default value, and .* a repeated parameter. If a required parameter is missing, a rejection occurs automatically and is handled as a 400 response.

Optional parameter with default value

val route =
  parameters('color, 'backgroundColor ? "white") { (color, backgroundColor) =>
    complete(s"The color is '$color' and the background is '$backgroundColor'")
  }

See also

Favorite site

author Zer0, MCPBot sitemap