options() = #{path => string(), model => atom(), verbose => boolean()}
state() = #{opts => options(), module => module()}
allowed_methods/2 | Retrieves the list of allowed methods from Trails metadata. |
announce_req/2 | Announces the Req. |
content_types_accepted/2 | Always returns "application/json *" with handle_post . |
content_types_provided/2 | Always returns "application/json" with handle_get . |
handle_get/2 | Returns the list of all entities. |
handle_post/2 | Creates a new entity. |
handle_post/3 | Persists a new entity. |
init/3 | Upgrades to cowboy_rest. |
resource_exists/2 | Returns false for POST, true otherwise. |
rest_init/2 | Announces the Req and moves on. |
allowed_methods(Req::cowboy_req:req(), State::state()) -> {[binary()], cowboy_req:req(), state()}
Retrieves the list of allowed methods from Trails metadata. Parses the metadata associated with this path and returns the corresponding list of endpoints.
See also: cowboy_rest:allowed_methods/2.
announce_req(Req::cowboy_req:req(), Opts::options()) -> cowboy_req:req()
Announces the Req.
If verbose := true
in Opts
for this handler
prints out a line indicating that endpoint that was hit.
See also: cowboy_rest:rest_init/2.
content_types_accepted(Req::cowboy_req:req(), State::state()) -> {[{{binary(), binary(), '*'}, atom()}], cowboy_req:req(), state()}
Always returns "application/json *" with handle_post
.
See also: cowboy_rest:content_types_accepted/2.
To do
content_types_provided(Req::cowboy_req:req(), State::state()) -> {[{binary(), atom()}], cowboy_req:req(), state()}
Always returns "application/json" with handle_get
.
See also: cowboy_rest:content_types_provided/2.
To do
handle_get(Req::cowboy_req:req(), State::state()) -> {iodata(), cowboy_req:req(), state()}
Returns the list of all entities.
Fetches the entities from SumoDB using the
model
provided in the options.
To do
handle_post(Req::cowboy_req:req(), State::state()) -> {{true, binary()} | false | halt, cowboy_req:req(), state()}
Creates a new entity.
To parse the body, it uses from_json/2
from the
model
provided in the options.
handle_post(Entity::sumo:user_doc(), Req1::cowboy_req:req(), State::state()) -> {{true, binary()}, cowboy_req:req(), state()}
Persists a new entity. The body must have been parsed beforehand.
init(Transport::{atom(), atom()}, Req::cowboy_req:req(), Opts::options()) -> {upgrade, protocol, cowboy_rest}
Upgrades to cowboy_rest.
Basically, just returns {upgrade, protocol, cowboy_rest}
See also: cowboy_rest:init/3.
resource_exists(Req::cowboy_req:req(), State::state()) -> {boolean(), cowboy_req:req(), state()}
Returns false
for POST, true
otherwise.
See also: cowboy_rest:resource_exists/2.
rest_init(Req::cowboy_req:req(), Opts::options()) -> {ok, cowboy_req:req(), state()}
Announces the Req and moves on.
If verbose := true
in Opts
for this handler
prints out a line indicating that endpoint that was hit.
See also: cowboy_rest:rest_init/2.
Generated by EDoc, Sep 12 2016, 12:29:07.