We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The idea is to give model implementors access to what currently is on sumo_rest handlers state. The tasks are as follows:
sr_entities_handler
sr_single_entity_handler
sr_state:state()
-module(sr_state). -opaque state() :: #{opts := sumo_rest:options() , id => binary() , entity => sumo:user_doc() , module := module() , user_opts := map() }. -export_type([state/0]). %% constructor, getters and setters -export([new/2, id/1, id/2, entity/1, entity/2, module/1, opts/1]). %% functions to work with user opts -export([set/3, retrieve/3, remove/2]). -spec set(Key::term(), Value::term(), state()) -> state(). -spec retrieve(Key::term(), state(), Default::T) -> T. -spec remove(Key::term(), state()) -> term().
-module(sr_request). -opaque req() :: #{body => sr_json:json() , headers := [{binary(), binary()}] , path := binary() , bindings := #{atom() => binary()} }. -export_type [req/0]. -export([new/1]). -spec new(cowboy_req:req()) -> req().
-type context() :: #{req := sr_request:req(), state := sr_state:state()}. -callback from_ctx(context()) -> sumo:user_doc(). -optional_callbacks([from_ctx/1]).
Turn from_json/1 into an optional callback
from_json/1
Change the handlers so that, whenever Module:from_json/1 is called now, before doing that, if Module:from_ctx/1 is defined, they use that one.
Module:from_json/1
Module:from_ctx/1
Update the docs and examples
The text was updated successfully, but these errors were encountered:
[#66] adding from_ctx callback
87640e9
[#66] fixed indentation
b872f11
[#66] adding dumb handler in order to test sr_request
3a37477
[#66] fixing PR comments
dacba63
ferigis
Successfully merging a pull request may close this issue.
The idea is to give model implementors access to what currently is on sumo_rest handlers state.
The tasks are as follows:
sr_entities_handler
andsr_single_entity_handler
states to a new ADT calledsr_state:state()
. Defined as follows:Turn
from_json/1
into an optional callbackChange the handlers so that, whenever
Module:from_json/1
is called now, before doing that, ifModule:from_ctx/1
is defined, they use that one.Update the docs and examples
The text was updated successfully, but these errors were encountered: