Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Headers = #{basic_auth => {User, Pass}, <<"Accept">> => <<"*/*">>},
- Options = #{async=>true, async_mode => binary,
- %called each time an event has been received
- handle_event => fun(_Nofin, _Reference, Notif_binary) ->
- Notif_fixed = fix_binary(Notif_binary),
- io:format("Notification before fix: ~p ~n~n~n", [Notif_binary]),
- io:format("Notification after fix: ~p ~n~n~n", [Notif_fixed])
- %decode JSON binary into a Erlang term with the JSX parser
- Notif_JSX = jsx:decode(Notif_fixed),
- io:format("JSX decode: ~p ~n~n~n", [Notif_JSX]),
- Notif = remove_key(Notif_JSX),
- io:format("DELETE PATH: ~p ~n~n~n", [Notif]),
- %insert to elasticsearch
- elastic_client:insert_notif(Notif)
- end},
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement