2015-10-07 15:55:04 +02:00
|
|
|
.. _form-field-request-vals-java:
|
|
|
|
|
|
|
|
|
|
Request Values: FormFields
|
|
|
|
|
==========================
|
|
|
|
|
|
|
|
|
|
A collection of pre-defined :ref:`request-vals-java` that can be used to extract header values from incoming requests.
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
2015-10-08 10:25:47 +02:00
|
|
|
``FormField`` request values allow extracting fields submitted as ``application/x-www-form-urlencoded`` values or concrete instances from HTTP requests.
|
2015-10-07 15:55:04 +02:00
|
|
|
|
|
|
|
|
The ``RequestVal`` builder is made up of 2 steps, initially you need to pick which Header to extract (``byName`` or
|
|
|
|
|
``byClass``) and then you need to pick if the header is optionally available or required (i.e. the route should not
|
|
|
|
|
match if the header is not present in the request). This is done using one of the below depicted methods::
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
--------
|
|
|
|
|
|
2015-10-08 10:25:47 +02:00
|
|
|
Extracting form fields of a certain primitive type from a request:
|
2015-10-07 15:55:04 +02:00
|
|
|
|
2015-10-08 10:25:47 +02:00
|
|
|
.. includecode:: ../../../code/docs/http/javadsl/server/FormFieldRequestValsExampleTest.java#simple
|
2015-10-07 15:55:04 +02:00
|
|
|
|
2015-10-08 10:25:47 +02:00
|
|
|
Extracting values of custom type from a request by providing a conversion function:
|
2015-10-07 15:55:04 +02:00
|
|
|
|
2015-10-08 10:25:47 +02:00
|
|
|
.. includecode:: ../../../code/docs/http/javadsl/server/FormFieldRequestValsExampleTest.java#custom-unmarshal
|