3.12 Get parameters from HTML forms
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog HTTP support
        • The HTTP server libraries
          • Get parameters from HTML forms
            • http_parameters/2
            • http_parameters/3
Availability::- use_module(library(http/http_parameters)).
Sourcehttp_parameters(+Request, ?Parameters, +Options)
In addition to http_parameters/2, the following options are defined.
form_data(-Data)
Return the entire set of provided Name=Value pairs from the GET or POST request. All values are returned as atoms.
attribute_declarations(:Goal)
If a parameter specification lacks the parameter options, call call(Goal, +ParamName, -Options) to find the options. Intended to share declarations over many calls to http_parameters/3. Using this construct the above can be written as below.
reply(Request) :-
        http_parameters(Request,
                        [ title(Title),
                          name(Name),
                          age(Age)
                        ],
                        [ attribute_declarations(param)
                        ]),
        ...

param(title, [optional(true)]).
param(name,  [length >= 2 ]).
param(age,   [integer]).