+htc,doc #18657,#18665 FormData javadsl and FormField docs
This commit is contained in:
parent
a17604500f
commit
4e7999cf0a
8 changed files with 93 additions and 45 deletions
|
|
@ -7,27 +7,19 @@ A collection of pre-defined :ref:`request-vals-java` that can be used to extract
|
|||
|
||||
Description
|
||||
-----------
|
||||
Header request values allow extracting ``HttpHeader`` values or concrete instances from HTTP requests.
|
||||
``FormField`` request values allow extracting fields submitted as ``application/x-www-form-urlencoded`` values or concrete instances from HTTP requests.
|
||||
|
||||
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::
|
||||
|
||||
RequestVal<T> instance()
|
||||
RequestVal<<Option<T>> optionalInstance()
|
||||
|
||||
RequestVal<String> value()
|
||||
RequestVal<Option<String>> optionalValue()
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
``Headers.byClass(Class[HttpHeader])``
|
||||
Extracting form fields of a certain primitive type from a request:
|
||||
|
||||
.. includecode:: ../../../code/docs/http/javadsl/server/HeaderRequestValsExampleTest.java
|
||||
:include: by-class
|
||||
.. includecode:: ../../../code/docs/http/javadsl/server/FormFieldRequestValsExampleTest.java#simple
|
||||
|
||||
``Headers.byName(String)``
|
||||
Extracting values of custom type from a request by providing a conversion function:
|
||||
|
||||
.. includecode:: ../../../code/docs/http/javadsl/server/HeaderRequestValsExampleTest.java
|
||||
:include: by-name
|
||||
.. includecode:: ../../../code/docs/http/javadsl/server/FormFieldRequestValsExampleTest.java#custom-unmarshal
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ match if the header is not present in the request). This is done using one of th
|
|||
Examples
|
||||
--------
|
||||
|
||||
``Headers.byClass(Class[HttpHeader])``
|
||||
Extracting a header by using a specific ``Header`` class (which are pre-defined in ``akka.http.javadsl.model.headers.*``):
|
||||
|
||||
.. includecode:: ../../../code/docs/http/javadsl/server/HeaderRequestValsExampleTest.java
|
||||
:include: by-class
|
||||
|
||||
``Headers.byName(String)``
|
||||
Extracting arbitrary headers by their name, for example custom headers (usually starting with ``X-...``):
|
||||
|
||||
.. includecode:: ../../../code/docs/http/javadsl/server/HeaderRequestValsExampleTest.java
|
||||
:include: by-name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue