Get HTTP GET or POST form-data, applying type validation,
default values, etc. Provided options are:
- attribute_declarations(:Goal)
- Causes the declarations for an attributed named A to be
fetched using
call(Goal, A, Declarations)
.
- form_data(-Data)
- Return the data read from the GET por POST request as a
list Name = Value. All data, including name/value pairs
used for Parms, is unified with Data.
The attribute_declarations hook allows sharing the declaration
of attribute-properties between many http_parameters/3 calls. In
this form, the requested attribute takes only one argument and
the options are acquired by calling the hook. For example:
...,
http_parameters(Request,
[ sex(Sex)
],
[ attribute_declarations(http_param)
]),
...
http_param(sex, [ oneof(male, female),
description('Sex of the person')
]).
- bug
- - If both request parameters (?name=value&...) and a POST are
present the parameters are extracted from the request parameters.
Still, as it is valid to have request parameters in a POST request
this predicate should not process POST requests. We will keep the
current behaviour as the it is not common for a request to have both
request parameters and a POST data of the type
application/x-www-form-urlencoded
.
In the unlikely event this poses a problem the request may be
specified as [method(get)
|Request].