z_dispatcher (zotonic_core v1.0.0-rc.17)

Manage dispatch lists (aka definitions for url patterns). Constructs named urls from dispatch lists.

Summary

Functions

Make the url an absolute url

Convert process state when code is changed

A list of dispatch rule arguments that shouldn't be considered with redirects. Used by controller_file_id and controller_redirect

Fetch the dispatchlist for the site.

Drop the portnumber from the hostname

Return the preferred hostname for the site

Handle casts.

Handling all non call/cast messages

Fetch the preferred hostname for this site

Fetch the preferred hostname, including port, for this site

Fetch the preferred hostname for SSL, including port, for this site

Initiates the server, loads the dispatch list into the webmachine dispatcher

Reload all dispatch lists. Finds new dispatch lists and adds them to the dispatcher

Starts the dispatch 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.

Update the dispatch list but don't reload it yet. Used when flushing all sites, see z:flush/0

Construct an uri from a named dispatch, assuming no parameters. Uses html escape.

Construct an uri from a named dispatch and the parameters. Uses html escape.

Construct an uri from a named dispatch and the parameters

Functions

abs_url(Url, Context)

Make the url an absolute url

code_change(OldVsn, State, Extra)

Convert process state when code is changed

dispatcher_args()

A list of dispatch rule arguments that shouldn't be considered with redirects. Used by controller_file_id and controller_redirect

dispatchinfo(Context)

-spec dispatchinfo(z:context() | pid() | atom()) -> {ok, DispatchInfo} | {error, noproc}
                      when
                          DispatchInfo ::
                              #{site := atom(),
                                hostname := binary() | undefined,
                                smtphost := binary() | undefined,
                                hostalias := [binary()],
                                redirect := boolean(),
                                dispatch_list := [z_sites_dispatcher:dispatch_rule()],
                                page_paths :=
                                    #{atom() | binary() => z_sites_dispatcher:dispatch_rsc_rule()}}.

Fetch the dispatchlist for the site.

drop_port(Hostname)

-spec drop_port(undefined | none | string() | binary()) -> undefined | binary().

Drop the portnumber from the hostname

handle_call(_, From, State)

Return the preferred hostname for the site

handle_cast(Msg, State)

Handle casts.

handle_info(Info, State)

Handling all non call/cast messages

hostname(Context)

-spec hostname(z:context()) -> binary() | undefined.

Fetch the preferred hostname for this site

hostname_port(Context)

-spec hostname_port(z:context()) -> binary() | undefined.

Fetch the preferred hostname, including port, for this site

hostname_ssl_port(Context)

-spec hostname_ssl_port(z:context()) -> binary() | undefined.

Fetch the preferred hostname for SSL, including port, for this site

init(Site)

Initiates the server, loads the dispatch list into the webmachine dispatcher

reload(Context)

Reload all dispatch lists. Finds new dispatch lists and adds them to the dispatcher

reload(_, Context)

start_link(Site)

Starts the dispatch server

terminate(Reason, State)

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(Context)

Update the dispatch list but don't reload it yet. Used when flushing all sites, see z:flush/0

url_for(Name, Context)

-spec url_for(Name, Context) -> Url
                 when Name :: atom() | binary(), Context :: z:context(), Url :: binary() | undefined.

Construct an uri from a named dispatch, assuming no parameters. Uses html escape.

url_for(Name, Args, Context)

-spec url_for(Name, Args, Context) -> Url
                 when
                     Name :: atom() | binary(),
                     Args :: proplists:proplist(),
                     Context :: z:context(),
                     Url :: binary() | undefined.

Construct an uri from a named dispatch and the parameters. Uses html escape.

url_for(Name, Args, Escape, Context)

-spec url_for(Name, Args, Escape, Context) -> Url
                 when
                     Name :: atom() | binary(),
                     Args :: proplists:proplist(),
                     Escape :: html | xml | none,
                     Context :: z:context(),
                     Url :: binary() | undefined.

Construct an uri from a named dispatch and the parameters