diff --git a/src/hello_stateless_handler.erl b/src/hello_stateless_handler.erl index 26c34db..7213433 100644 --- a/src/hello_stateless_handler.erl +++ b/src/hello_stateless_handler.erl @@ -127,8 +127,6 @@ transport_param(Key, Context) -> %% Please take this into consideration when designing your system. -spec transport_param(atom(), context(), any()) -> any(). transport_param(Key, #stateless_context{transport_params = Params}, Default) -> - transport_param(Key, Params, Default); -transport_param(Key, Params, Default) -> proplists:get_value(Key, Params, Default). %% ---------------------------------------------------------------------------------------------------- @@ -137,10 +135,9 @@ transport_param(Key, Params, Default) -> %% @doc stateless handler process function for hello_binding -spec handler(#binding{}, hello_binding:peer(), pid(), hello:transport_params()) -> any(). handler(#binding{protocol = Protocol, log_url = Endpoint, callback_mod = CallbackModule}, Peer, Transport, TransportParams) -> - Context = #stateless_context{transport_params = TransportParams}, receive {?INCOMING_MSG_MSG, Message} -> - case run_binary_request(Protocol, CallbackModule, Context, Message) of + case run_binary_request(Protocol, CallbackModule, TransportParams, Message) of {ok, Request, Response} -> hello_request_log:request(CallbackModule, self(), Endpoint, Request, Response), BinResp = hello_proto:encode(Response), @@ -159,9 +156,10 @@ handler(#binding{protocol = Protocol, log_url = Endpoint, callback_mod = Callbac end. %% @private --spec run_binary_request(module(), module(), #stateless_context{}, binary()) -> +-spec run_binary_request(module(), module(), hello:transport_params(), binary()) -> {ok, hello_proto:request(), hello_proto:response()} | {error, hello_proto:response()}. -run_binary_request(Protocol, CallbackModule, Context, BinRequest) -> +run_binary_request(Protocol, CallbackModule, TransportParams, BinRequest) -> + Context = #stateless_context{transport_params = TransportParams}, case hello_proto:decode(Protocol, BinRequest) of Req = #request{} -> {ok, Req, do_single_request(CallbackModule, Context, Req)};