Copyright © 2009-2021 Marc Worrell
Behaviours: cowboy_middleware, gen_server.
Authors: Marc Worrell (marc@worrell.nl).
bindings() = [dispatch_compiler:binding()]
dispatch() = #dispatch_controller{dispatch_rule = atom(), controller = atom(), controller_options = list(), path_tokens = [binary()], bindings = bindings(), context = z:context()} | #dispatch_nomatch{site = atom(), host = binary(), path_tokens = [binary()], bindings = bindings(), context = #context{} | undefined} | redirect() | redirect_protocol() | stop_request()
dispatch_rule() = dispatch_compiler:dispatch_rule()
hostname() = binary() | string()
redirect() = {redirect, Site::atom(), NewPathOrURI::binary() | undefined, IsPermanent::boolean()}
redirect_protocol() = {redirect_protocol, http | https, Host::binary(), IsPermanent::boolean()}
stop_request() = {stop_request, pos_integer()}
trace() = #{path := binary() | [binary()] | undefined, step := trace_step(), args := proplists:proplist()}
trace_step() = undefined | match | try_match | dispatch_rewrite | forced_protocol_switch | notify_dispatch | rewrite_id | rewrite_match | rewrite_nomatch
code_change/3 | Convert process state when code is changed. |
collect_dispatchrules/0 | Collect all dispatch rules for all running sites, normalize and filter them. |
collect_dispatchrules/1 | Collect all dispatch rules for all sites, normalize and filter them. |
dispatch/2 | Match the host and path to a dispatch rule. |
dispatch/5 | |
dispatch_trace/2 | |
dispatch_trace/3 | |
execute/2 | Cowboy middleware, route the new request. |
fetch_dispatchinfo/1 | Fetch dispatch rules for a specific site. |
get_fallback_site/0 | Retrieve the fallback site. |
get_site_for_hostname/1 | Fetch the site handling the given hostname (with optional port) (debug function). |
handle_call/3 | Trap unknown calls. |
handle_cast/2 | Load all dispatch rules, if anything changed then recompile the dispatcher(s). |
handle_info/2 | Handling all non call/cast messages. |
init/1 | Initiates the server. |
is_bind_language/2 | Callback for the dispatch compiler, try to bind a language. |
start_link/0 | Starts the server. |
start_link/1 | |
terminate/2 | This function is called by a gen_server when it is about to terminate. |
update_dispatchinfo/0 | Collect dispatch information from all sites and recompiles the dispatch rules. |
update_hosts/0 | Update the host/site mappings. |
code_change(OldVsn, State, Extra) -> {ok, NewState}
Convert process state when code is changed
collect_dispatchrules() -> any()
Collect all dispatch rules for all running sites, normalize and filter them.
collect_dispatchrules(Site) -> any()
Collect all dispatch rules for all sites, normalize and filter them.
dispatch(Req::cowboy_req:req(), Env::cowboy_middleware:env()) -> dispatch()
Match the host and path to a dispatch rule.
dispatch(Method::binary() | string(), Host::binary() | string(), Path::binary() | string(), IsSsl::boolean(), OptTracerPid::pid() | undefined) -> dispatch()
dispatch_trace(Path::binary(), Context::z:context()) -> {ok, [trace()]} | {error, timeout}
dispatch_trace(Protocol::http | https, Path::binary(), Context::z:context()) -> {ok, [trace()]} | {error, timeout}
execute(Req, Env) -> {ok, Req, Env} | {stop, Req}
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_dispatchinfo(SiteOrContext) -> any()
Fetch dispatch rules for a specific site.
get_fallback_site() -> {ok, atom()} | undefined
Retrieve the fallback site.
get_site_for_hostname(Hostname::string() | binary() | '*') -> {ok, atom()} | undefined
Fetch the site handling the given hostname (with optional port) (debug function)
handle_call(Message::Request, From, State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}
Trap unknown calls
handle_cast(Message::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
Load all dispatch rules, if anything changed then recompile the dispatcher(s)
handle_info(Info, State) -> any()
Handling all non call/cast messages
init(Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}
Initiates the server.
is_bind_language(Match, Context) -> any()
Callback for the dispatch compiler, try to bind a language
start_link() -> {ok, pid()} | ignore | {error, term()}
Starts the server
start_link(Args::list()) -> {ok, pid()} | ignore | {error, term()}
terminate(Reason, State) -> void()
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.
update_dispatchinfo() -> ok
Collect dispatch information from all sites and recompiles the dispatch rules.
update_hosts() -> ok
Update the host/site mappings
Generated by EDoc