Advertisement
Guest User

Untitled

a guest
Apr 11th, 2019
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.81 KB | None | 0 0
  1.     Headers = #{basic_auth => {User, Pass}, <<"Accept">> => <<"*/*">>},
  2.     Options = #{async=>true, async_mode => binary,
  3.  
  4.       %called each time an event has been received
  5.       handle_event => fun(_Nofin, _Reference, Notif_binary) ->
  6.  
  7.  
  8.         Notif_fixed = fix_binary(Notif_binary),
  9.         io:format("Notification before fix: ~p ~n~n~n", [Notif_binary]),
  10.         io:format("Notification after fix: ~p ~n~n~n", [Notif_fixed])
  11.  
  12.         %decode JSON binary into a Erlang term with the JSX parser
  13.         Notif_JSX = jsx:decode(Notif_fixed),
  14.  
  15.         io:format("JSX decode: ~p ~n~n~n", [Notif_JSX]),
  16.  
  17.         Notif = remove_key(Notif_JSX),
  18.  
  19.         io:format("DELETE PATH: ~p ~n~n~n", [Notif]),
  20.  
  21.         %insert to elasticsearch
  22.         elastic_client:insert_notif(Notif)
  23.  
  24.                       end},
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement