Пишу http_handler для cowboya, в котором делаю парсинг приходящего xml запроса библиотекой exomler
https://github.com/kostyushkin/exomler.
handle(Req, State) ->
{ok, Data, Req2} = cowboy_req:body(Req),
io:format("Request body: ~p~n",[Data]),
{Tag, Attrs, Content} = exomler:decode(Data),
io:format("Attributes: ~p~n", [Attrs]),
Attr_bin = lists:keyfind(<<"typeId">>, 1, Attrs),
io:format("Attr value: ~p~n",[Attr_bin]),
{Name_bin, Value_bin} = Attr_bin,
io:format("value: ~p~n",[Value_bin]),
Attr_value = binary_to_term(Value_bin),
io:format("value: ~p~n",[Attr_value]),
{ok, Req2, State}.
Определив нужный тег пытаюсь конвертировать его bif функцией binary_to_term(), получаю
=ERROR REPORT==== 18-Jul-2013::17:10:04 ===
** Cowboy handler store_handler terminating in handle/2
for the reason error:badarg
** Handler state was undefined_state
.....
** Stacktrace: [{erlang,binary_to_term,[<<"events">>],[]},
{store_handler,handle,2,
[{file,"/home/prots/NetBeansProjects/ProxyNode/src/store_handler.erl"},
{line,23}]},
{cowboy_handler,handler_handle,4,
[{file,"src/cowboy_handler.erl"},{line,119}]},
{cowboy_protocol,execute,4,
[{file,"src/cowboy_protocol.erl"},
{line,523}]}]
В чем может быть проблема? Мне нужно получить строку, по которой я буду выполнять поиск в уже заполненной ets таблице.