Browse Source

n4u_xhr (cowboy 2.0.9)

221V 3 years ago
parent
commit
e1d4d7fdfb
2 changed files with 5 additions and 5 deletions
  1. 1 1
      ebin/n4u.app
  2. 4 4
      src/protocols/n4u_xhr.erl

+ 1 - 1
ebin/n4u.app

@@ -2,7 +2,7 @@
   {description, "N4U WebSocket Application Server"},
   {vsn, "4.4.20"},
   {applications, [kernel, stdlib, asn1, public_key, ssl, crypto, ranch, cowboy, fs, active, sh, gproc, nitro]},
-  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n4u_proto, n4u_relay, n4u_error, n4u_io, n4u_log, n4u_mq, n4u_pickle, n4u_query, n4u_secret, n4u_session, n4u_syn, n4u_client, n4u_file, n4u_heart, n4u_http, n4u_nitrogen, n4u_text, wf, wf_convert, wf_utils]},
+  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n4u_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n4u_proto, n4u_relay, n4u_error, n4u_io, n4u_log, n4u_mq, n4u_pickle, n4u_query, n4u_secret, n4u_session, n4u_syn, n4u_client, n4u_file, n4u_heart, n4u_http, n4u_nitrogen, n4u_text, wf, wf_convert, wf_utils]},
   {registered, [n4u_sup]},
   {mod, {n4u_app, []}},
   {env, []}

+ 4 - 4
src/protocols/n4u_xhr.erl

@@ -1,5 +1,5 @@
 -module(n4u_xhr).
--behaviour(cowboy_http_handler).
+-behaviour(cowboy_handler).
 
 -include_lib("n4u/include/n4u.hrl").
 
@@ -7,11 +7,11 @@
 % stream bridge to XHR
 
 % cowboy websocket backend
--export([init/3, handle/2, info/3, terminate/3]).
+-export([init/2, handle/2, info/3, terminate/3]).
 
 
 % 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).
 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({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.