z_sites_dispatcher (zotonic_core v1.0.0-rc.12)
Link to this section Summary
Functions
Convert process state when code is changed
Collect all dispatch rules for all running sites, normalize and filter them.
Collect all dispatch rules for all sites, normalize and filter them.
Match the host and path to a dispatch rule.
Dispatch a path for a host, return the extracted dispatch information and bindings. Used for matching URLs to dispatch rules and ids.
Dispatch an URL, return the extracted dispatch information and bindings. Used for matching URLs to dispatch rules and ids.
Cowboy middleware, route the new request. Continue with the cowmachine, requests a redirect or return a 400 on an unknown host. The cowmachine_proxy middleware must have been called before this.
Fetch dispatch rules for a specific site.
Retrieve the fallback site.
Fetch the site handling the given hostname (with optional port)
Fetch the site handling the given URL. Scheme is not checked.
Trap unknown calls
Load all dispatch rules, if anything changed then recompile the dispatcher(s)
Handling all non call/cast messages
Initiates the server.
Callback for the dispatch compiler, try to bind a language
Starts the server
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.
Collect dispatch information from all sites and recompiles the dispatch rules.
Update the host/site mappings
Link to this section Types
Link to this type
bindings/0
-type bindings() :: [dispatch_compiler:binding()].
Link to this type
dispatch/0
-type dispatch() :: #dispatch_controller{} | #dispatch_nomatch{} | redirect() | redirect_protocol() | stop_request().
Link to this type
dispatch_rule/0
-type dispatch_rule() :: dispatch_compiler:dispatch_rule().
Link to this type
hostname/0
-type hostname() :: binary() | string().
Link to this type
redirect/0
-type redirect() ::
{redirect, Site :: atom(), NewPathOrURI :: binary() | undefined, IsPermanent :: boolean()}.
Link to this type
redirect_protocol/0
-type redirect_protocol() ::
{redirect_protocol, http | https, Host :: binary(), IsPermanent :: boolean()}.
Link to this type
stop_request/0
-type stop_request() :: {stop_request, pos_integer()}.
Link to this type
trace/0
-type trace() :: #{path := binary() | [binary()] | undefined, step := trace_step(), args := proplists:proplist()}.
Link to this type
trace_step/0
-type trace_step() ::
undefined | match | try_match | dispatch_rewrite | forced_protocol_switch | notify_dispatch |
rewrite_id | rewrite_match | rewrite_nomatch.
Link to this section Functions
Link to this function
code_change(OldVsn, State, Extra)
Link to this function
collect_dispatchrules()
Link to this function
collect_dispatchrules(Site)
Link to this function
dispatch(Req, Env)
-spec dispatch(cowboy_req:req(), cowboy_middleware:env()) -> dispatch().
Link to this function
dispatch(Method, Host, Path, IsSsl, OptTracerPid)
-spec dispatch(binary() | string(), binary() | string(), binary() | string(), boolean(), pid() | undefined) -> dispatch().
Link to this function
dispatch_path(Path, Context)
-spec dispatch_path(binary() | string(), z:context()) -> {ok, map()} | {error, non_neg_integer() | invalid}.
Link to this function
dispatch_trace(Path, Context)
Link to this function
dispatch_trace(Protocol, Path, Context)
Link to this function
dispatch_url(Url)
-spec dispatch_url(binary() | string()) -> {ok, map()} | {error, non_neg_integer() | invalid}.
Link to this function
execute(Req, Env)
-spec execute(Req, Env) -> {ok, Req, Env} | {stop, Req} when Req :: cowboy_req:req(), Env :: cowboy_middleware:env().
Link to this function
fetch_dispatchinfo(SiteOrContext)
Link to this function
get_fallback_site()
-spec get_fallback_site() -> {ok, atom()} | undefined.
Link to this function
get_site_for_hostname(Hostname)
-spec get_site_for_hostname(string() | binary() | '*') -> {ok, atom()} | undefined.
Link to this function
get_site_for_url(Url)
-spec get_site_for_url(binary() | string()) -> {ok, atom()} | undefined.
Link to this function
handle_call(Message, From, State)
Link to this function
handle_cast(Message, State)
Link to this function
handle_info(Info, State)
Link to this function
init(Args)
Link to this function
is_bind_language(Match, Context)
Link to this function
start_link()
-spec start_link() -> {ok, pid()} | ignore | {error, term()}.
Link to this function
start_link(Args)
-spec start_link(list()) -> {ok, pid()} | ignore | {error, term()}.
Link to this function
terminate(Reason, State)
Link to this function
update_dispatchinfo()
-spec update_dispatchinfo() -> ok.
Link to this function
update_hosts()
-spec update_hosts() -> ok.