Gemini.Site behaviour (Gemini v0.2.0)
Base module for sites.
Use it with use Gemini.Site.
If the use call is made with the option :check_path then forward_request/2 will only be called if the URL path matches exactly.
It is a good idea to enable that for "leaf" sites, i.e. sites that do not forward to other sites.
start_link receives a list with three arguments:
- the name to register the GenServer
- the path
- arguments from the site-map
The server state must contain the path and path(state) must return that path.
Link to this section Summary
Callbacks
Handle/Forward request. Think of it as GenServer.handle_call/3 without the middle from argument.
Return path supplied in start_link/1 using the state.
Start site's GenServer.
Link to this section Types
status_decl()
Specs
status_decl() ::
{pos_integer(), non_neg_integer()}
| :input
| :sensitive_input
| :success
| :redirect_temporary
| :redirect_permanent
| :temporary_failure
| :server_unavailable
| :cgi_error
| :proxy_error
| :slow_down
| :permanent_failure
| :not_found
| :gone
| :proxy_request_refused
| :bad_request
| :client_certificate_required
| :certificate_not_authorised
| :certificate_not_valid
Link to this section Functions
make_response(status, meta, body, attrs)
Specs
make_response( status :: status_decl(), meta :: binary() | {atom(), any()}, body :: any(), attrs :: keyword() | [] ) :: Gemini.Response.t()
status(arg1)
Specs
status(status_decl()) :: {pos_integer(), non_neg_integer()}
Return two digit status tuple.
Link to this section Callbacks
forward_request(request, state)
Specs
forward_request(request :: Gemini.Request.t(), state :: any()) :: {:reply, any(), any()}
Handle/Forward request. Think of it as GenServer.handle_call/3 without the middle from argument.
path(state)
Specs
Return path supplied in start_link/1 using the state.
start_link(list)
Specs
start_link(list()) :: GenServer.on_start()
Start site's GenServer.
- the name to register the GenServer
- the path
- arguments from the site-map