
http_path.pl -- Abstract specification of HTTP server locationsThis module provides an abstract specification of HTTP server locations that is inspired on absolute_file_name/3. The specification is done by adding rules to the dynamic multifile predicate http:location/3. The speficiation is very similar to file_search_path/2, but takes an additional argument with options. Currently only one option is defined:
The default priority is 0. Note however that notably libraries may decide to provide a fall-back using a negative priority. We suggest -100 for such cases.
This library predefines a single location at priority -100:
http:prefix
To serve additional resource files such as CSS, JavaScript and icons,
see library(http/http_server_files).
Here is an example that binds /login to login/1. The user can reuse
this application while moving all locations using a new rule for the
admin location with the option [priority(10)].
:- multifile http:location/3.
:- dynamic http:location/3.
http:location(admin, /, []).
:- http_handler(admin(login), login, []).
login(Request) :-
...
http:location(+Alias, -Expansion, -Options) is nondet[multifile]/. Options currently only supports the
priority of the path. If http:location/3 returns multiple
solutions the one with the highest priority is selected. The
default priority is 0.
This library provides a default for the abstract location
root. This defaults to the setting http:prefix or, when not
available to the path /. It is adviced to define all
locations (ultimately) relative to root. For example, use
root('home.html') rather than '/home.html'.
http_absolute_uri(+Spec, -URI) is dethttp://) URI for
the abstract specification Spec. Use http_absolute_location/3 to
create references to locations on the same server.
http_absolute_location(+Spec, -Path, +Options) is det
http_clean_location_cache