Browse Source

n2o_http to n4u_http

221V 3 years ago
parent
commit
83d2d24789
4 changed files with 23 additions and 17 deletions
  1. 1 1
      ebin/n4u.app
  2. 1 1
      src/endpoints/n2o_proto.erl
  3. 0 15
      src/protocols/n2o_http.erl
  4. 21 0
      src/protocols/n4u_http.erl

+ 1 - 1
ebin/n4u.app

@@ -2,7 +2,7 @@
   {description, "N4U WebSocket Application Server"},
   {description, "N4U WebSocket Application Server"},
   {vsn, "4.4.20"},
   {vsn, "4.4.20"},
   {applications, [kernel, stdlib, asn1, public_key, ssl, crypto, ranch, cowboy, fs, active, sh, gproc, nitro]},
   {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, n2o_proto, n2o_relay, n4u_error, n2o_io, n2o_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n4u_heart, n2o_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
+  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n4u_error, n2o_io, n2o_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n4u_heart, n4u_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
   {registered, [n4u_sup]},
   {registered, [n4u_sup]},
   {mod, {n4u_app, []}},
   {mod, {n4u_app, []}},
   {env, []}
   {env, []}

+ 1 - 1
src/endpoints/n2o_proto.erl

@@ -9,7 +9,7 @@ protocols() -> wf:config(n2o,protocols,[ n4u_heart,
                                          n2o_nitrogen,
                                          n2o_nitrogen,
                                          n2o_file,
                                          n2o_file,
                                          n4u_client,
                                          n4u_client,
-                                         n2o_http ]).
+                                         n4u_http ]).
 
 
 terminate(_,#cx{module=Module}) -> catch Module:event(terminate).
 terminate(_,#cx{module=Module}) -> catch Module:event(terminate).
 init(_Transport, Req, _Opts, _) ->
 init(_Transport, Req, _Opts, _) ->

+ 0 - 15
src/protocols/n2o_http.erl

@@ -1,15 +0,0 @@
--module(n2o_http).
--include_lib("n4u/include/n4u.hrl").
--compile([export_all, nowarn_export_all]).
-
-%% ws.send(enc(tuple(atom('http'), bin(url), bin(method), bin(body), [])));
-
-info(#http{} = Message, Req, State) ->
-    wf:info(?MODULE, "Http Message: ~p",[Message]),
-    Module = State#cx.module,
-    Reply = try Module:event(Message)
-          catch E:R -> Error = wf:stack(E,R), wf:error(?MODULE,"Catch: ~p:~p~n~p",Error), Error end,
-    {reply,wf:format({io,n2o_nitrogen:render_actions(wf:actions()),Reply}),Req,State};
-
-info(Message, Req, State) -> {unknown,Message, Req, State}.
-

+ 21 - 0
src/protocols/n4u_http.erl

@@ -0,0 +1,21 @@
+-module(n4u_http).
+-include_lib("n4u/include/n4u.hrl").
+
+-export([info/3]).
+
+
+%% ws.send(enc(tuple(atom('http'), bin(url), bin(method), bin(body), [])));
+
+
+info(#http{} = Message, Req, State) ->
+  wf:info(?MODULE, "Http Message: ~p", [Message]),
+  Module = State#cx.module,
+  Reply = try Module:event(Message)
+  catch E:R:Stk ->
+    wf:error(?MODULE, "Catch: ~p:~p~n~p", [E, R, Stk]),
+    [E, R, Stk]
+  end,
+  {reply, wf:format({io, n2o_nitrogen:render_actions(erlang:get(actions)), Reply}), Req, State};
+
+info(Message, Req, State) -> {unknown, Message, Req, State}.
+