Skip to content

Instantly share code, notes, and snippets.

@neeraj9
Last active February 9, 2019 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neeraj9/fdf06dbe7afcfee0a083e9d572a9325b to your computer and use it in GitHub Desktop.
Save neeraj9/fdf06dbe7afcfee0a083e9d572a9325b to your computer and use it in GitHub Desktop.
BeamParticle Erlang Dynamic function for /post/ HTTP POST JSON handler
#!erlang
%% Sample Erlang (OTP-20) function to return what was passed in as the first argument.
%% Notice that this template works for the /post/<thisfun> interface, where
%% json input is passed in the first argument postBody, while the response
%% is a binary or a string, which must be json as well.
fun (Body, Context) ->
DecodedMap = jiffy:decode(Body, [return_maps]),
%% TODO process decoded_map
Result = DecodedMap,
jiffy:encode(Result)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment