basho / webmachine (http://webmachine.basho.com/)
A REST-based system for building web applications.
| commit 82: | ab37abfaf7ad |
| parent 81: | 15cd6ed98abc |
| child 83: | d34f3983bc66 |
host-based dispatching
dispatch rules can now take two different forms:
The old form: {PathMatchSpec, Module, Paramters}
The new form: {HostMatchSpec, [{PathMatchSpec, Module, Parameters}]}
The former is equivalent to the latter with HostMatchSpec={['*'],'*'}
HostMatchSpec is matched against one of (in order of preference):
X-Forwarded-For, X-Forwarded-Host, X-Forwarded-Server, Host
HostMatchSpec can have two forms:
{[HostPart], PortSpec}
or
[HostPart]
The latter is equivalent to the former with PortSpec='*'
The list of host parts is matched against the hostname extracted from a header in much the same way that PathMatchSpec is matched against the path.
Examples:
{[], root_resource, [x]}.
{['*'], [{[], root_resource, [x]}]}.
{{['*'],'*'}, [{[], root_resource, [x]}]}.
Will each match the root path of any host.
{["example","com"], [{[], root_resource, [x]},
{["static"], static_resource, [y]}]}.
Will dispatch the root of example.com to root_resource and example.com/static to static_resource.
{['*',"example","com"], [{[], root_resource, [x]},
{["static"], static_resource, [y]}]}.
Will do the same as above, but also for any subdomains of example.com.
{{[host,"local"], 8000}, [{[], res_A, [x]}]}.
{{[host,"local"], 8001}, [{[], res_B, [x]}]}.
Will dispatch requests to ?.local:8000/ to res_A and requests to ?.local:8001/ to resB, binding the host part immediately preceeding ".local" to 'host', such that wrq:get_path_info(host, ReqData) would return the matched string.
11 months ago
NB: This is not the latest revision. For the latest view, go to tip.
| filename | size | last modified | ||
|---|---|---|---|---|
| .hg_empty_dir | 0 B | 18 months ago | initial import |
