
http_parameters.pl -- Extract parameters (GET and POST) from HTTP requestsThis module is used to extract the value of GET or POST parameters from an HTTP request. The typical usage is e.g.,
:- http_handler('/register_user', register_user, []).
register_user(Request) :-
http_parameters(Request,
[ name(Name, []),
sex(Sex, [oneof([male,female])]),
birth_year(BY, [between(1850,10000)])
]),
register_user(Name, Sex, BY),
html_reply_page(title('New user added'),
...).
http_parameters(+Request, ?Parms) is det
http_parameters(+Request, ?Parms, :Options) is detcall(Goal, A, Declarations).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')
]).
posted_form(+Request, -Data) is det[private]
fill_parameters(+ParamDecls, +FormData, +DeclGoal)[private]
http_convert_parameters(+Data, ?Params) is det
http_convert_parameters(+Data, ?Params, :AttrDecl) is det
http_parameters(Request, Params) :-
http_read_data(Request, Data, []),
http_convert_parameters(Data, Params).
http_convert_parameter(+Options, +FieldName, +ValueIn, -ValueOut) is det
check_type3(+Type, +ValueIn, -ValueOut) is semidet[private]
check_type2(+Type, +ValueIn) is semidet[private]
truth(+In, -Boolean) is semidet[private]
http_parameters(+Request, ?Parms) is det
http_parameters(+Request, ?Parms, :Options) is detcall(Goal, A, Declarations).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')
]).
http_convert_parameters(+Data, ?Params) is det
http_convert_parameters(+Data, ?Params, :AttrDecl) is det
http_parameters(Request, Params) :-
http_read_data(Request, Data, []),
http_convert_parameters(Data, Params).