|
@@ -1,5 +1,5 @@
|
|
-module(n4u_xhr).
|
|
-module(n4u_xhr).
|
|
--behaviour(cowboy_http_handler).
|
|
|
|
|
|
+-behaviour(cowboy_handler).
|
|
|
|
|
|
-include_lib("n4u/include/n4u.hrl").
|
|
-include_lib("n4u/include/n4u.hrl").
|
|
|
|
|
|
@@ -7,11 +7,11 @@
|
|
% stream bridge to XHR
|
|
% stream bridge to XHR
|
|
|
|
|
|
% cowboy websocket backend
|
|
% cowboy websocket backend
|
|
--export([init/3, handle/2, info/3, terminate/3]).
|
|
|
|
|
|
+-export([init/2, handle/2, info/3, terminate/3]).
|
|
|
|
|
|
|
|
|
|
% XHR
|
|
% XHR
|
|
-init(T, R, O) -> xhr(n4u_proto:init(T, R, [{formatter, json}|O], xhr)).
|
|
|
|
|
|
+init(R, O) -> xhr(n4u_proto:init([], R, [{formatter, json}|O], xhr)).
|
|
|
|
|
|
handle(R, S) -> body(cowboy_req:body(R), S).
|
|
handle(R, S) -> body(cowboy_req:body(R), S).
|
|
info(M, R, S) -> xhr(n4u_proto:info(M, R, S)).
|
|
info(M, R, S) -> xhr(n4u_proto:info(M, R, S)).
|
|
@@ -28,5 +28,5 @@ xhr({ok, R, S}) -> {ok, R, S};
|
|
xhr({shutdown, R, S}) -> {shutdown, R, S};
|
|
xhr({shutdown, R, S}) -> {shutdown, R, S};
|
|
xhr({reply, D, R, S}) -> {ok, reply(D, R, 200), S}.
|
|
xhr({reply, D, R, S}) -> {ok, reply(D, R, 200), S}.
|
|
|
|
|
|
-reply(D, R, Code) -> {ok, R2} = cowboy_req:reply(Code, [], D, R), R2.
|
|
|
|
|
|
+reply(D, R, Code) -> cowboy_req:reply(Code, [], D, R). % R2.
|
|
|
|
|