+doc,htp #18496 example for formfield
This commit is contained in:
parent
2927568225
commit
afcd3e2127
2 changed files with 26 additions and 0 deletions
|
|
@ -24,5 +24,23 @@ class FormFieldDirectivesExamplesSpec extends RoutingSpec {
|
|||
responseAs[String] shouldEqual "Request is missing required form field 'color'"
|
||||
}
|
||||
}
|
||||
"formField" in {
|
||||
val route =
|
||||
formField('color) { color =>
|
||||
complete(s"The color is '$color'")
|
||||
} ~
|
||||
formField('id.as[Int]) { id =>
|
||||
complete(s"The id is '$id'")
|
||||
}
|
||||
|
||||
Post("/", FormData("color" -> "blue")) ~> route ~> check {
|
||||
responseAs[String] shouldEqual "The color is 'blue'"
|
||||
}
|
||||
|
||||
Get("/") ~> Route.seal(route) ~> check {
|
||||
status shouldEqual StatusCodes.BadRequest
|
||||
responseAs[String] shouldEqual "Request is missing required form field 'color'"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue