options() = #{path => string(), model => atom(), verbose => boolean()}
state() = #{opts => options(), id => binary(), entity => sumo:user_doc(), module => module()}
delete_resource/2 | Deletes the found entity. |
handle_get/2 | Renders the found entity. |
handle_patch/2 | Updates the found entity. |
handle_put/2 | Updates the entity if found, otherwise it creates a new one. |
resource_exists/2 | Verifies if there is an entity with the given id . |
rest_init/2 | Announces the Req and moves on. |
delete_resource(Req::cowboy_req:req(), State::state()) -> {boolean() | halt, cowboy_req:req(), state()}
Deletes the found entity.
See also: resource_exists/2.
handle_get(Req::cowboy_req:req(), State::state()) -> {iodata(), cowboy_req:req(), state()}
Renders the found entity.
See also: resource_exists/2.
handle_patch(Req::cowboy_req:req(), State::state()) -> {{true, binary()} | false | halt, cowboy_req:req(), state()}
Updates the found entity.
To parse the body, it uses update/2
from the
model
provided in the options.
See also: resource_exists/2.
handle_put(Req::cowboy_req:req(), State::state()) -> {{true, binary()} | false | halt, cowboy_req:req(), state()}
Updates the entity if found, otherwise it creates a new one.
To parse the body, it uses either update/2
or
from_json/2
(if defined) or from_json/1
from the model
provided in the options.
See also: resource_exists/2.
resource_exists(Req::cowboy_req:req(), State::state()) -> {boolean(), cowboy_req:req(), state()}
Verifies if there is an entity with the given id
.
The provided id must be the value for the id field in
SumoDb. If the entity is found, it's kept in the
state.
See also: cowboy_rest:resource_exists/2, sumo:find/2.
rest_init(Req::cowboy_req:req(), Opts::options()) -> {ok, cowboy_req:req(), state()}
Announces the Req and moves on.
It extracts the :id
binding from the Req and leaves it in
the id
key in the state.
See also: cowboy_rest:rest_init/2.
Generated by EDoc, Sep 12 2016, 12:29:07.