Hi,
Pushed something ready for evaluation. See examples/
demo_rest.pl in the
comment. The brief summary is:
- Restricted ID in id(ID) to be an atom. Used to be an arbitrary
ground term. My guess is that this will break not much. Hope
I'm right here.
- If a handler is of the form
:- http_handler(PathAlias(a/B/c), ..., [id(x)])
we may use:
+ http_location_by_id(x, Path)
Returns the known prefix path, i.e., the materialization of
PathAlias('a/') in this case. This is as it used to be.
+ http_location_by_id(x(V), Path)
Where the number of arguments matches the number of variables
in the
path segments. In the above case this materializes
PathAlias(a/V/c), after encoding V.
From http_location_by_id/2, this functionality is available in
http_link_to_id/3, which allows using
http_link_to_id(x(aap), [name('Bob')], URL)
binding URL to the materialization of PathAlias(a/aap/c) followed
by ?name=Bob
This can also used in html_write as
a(href(location_by_id(x(aap)+[name('Bob')])), ...)
or, abbreviating `location_by_id` as `#`:
a(href(#(x(aap)+[name('Bob')])), ...)
Another place that accepts these notations is http_redirect/2.
The code is in the devel master. Note that this may still change if
somone comes with a better plan.
Does this satisfy the requirements and is this sufficiently natural?
Cheers --- Jan