formField
Example
final Route route = route(
formField("color", color ->
complete("The color is '" + color + "'")
),
formField(StringUnmarshallers.INTEGER, "id", id ->
complete("The id is '" + id + "'")
)
);
// tests:
final FormData formData = FormData.create(Pair.create("color", "blue"));
testRoute(route).run(HttpRequest.POST("/").withEntity(formData.toEntity()))
.assertEntity("The color is 'blue'");
testRoute(route).run(HttpRequest.GET("/"))
.assertStatusCode(StatusCodes.BAD_REQUEST)
.assertEntity("Request is missing required form field 'color'");
Contents