From b74418d7cba4dd4011edec86667d7f5c1312c248 Mon Sep 17 00:00:00 2001 From: 5HT Date: Mon, 29 Jan 2024 20:31:45 +0200 Subject: [PATCH] nitro sample --- config/config.exs | 18 ++++++++---------- lib/up_nitro.ex | 6 ++---- lib/up_route.ex | 8 +------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/config/config.exs b/config/config.exs index 5ae79cd..7052a1c 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,21 +1,19 @@ import Config config :n2o, + routes: UP.Route, pickler: :n2o_secret, - app: :up, - points: - [{:_, [], - [{["n2o", :"..."], [], :cowboy_static, {:dir, 'deps/n2o/priv', [{:mimetypes, :cow_mimetypes, :all}]}}, - {["app", :"..."], [], :cowboy_static, {:dir, 'priv', [{:mimetypes, :cow_mimetypes, :all}]}}, - {["ws", :"..."], [], :n2o_cowboy, []} ]}], mq: :n2o_syn, rest: 5010, ws: 5011, tables: [:cookies, :file, :caching, :async], protocols: [:n2o_heart, :nitro_n2o, :n2o_ftp], - routes: UP.Route + points: + [{:_, [], + [{["app", :"..."], [], :cowboy_static, {:dir, 'priv', [{:mimetypes, :cow_mimetypes, :all}]}}, + {["ws", :"..."], [], :n2o_cowboy, []}]}] config :kvs, - dba: :kvs_rocks, - dba_st: :kvs_st, - schema: [:kvs, :kvs_stream, :bpe_metainfo, MED] + dba: :kvs_mnesia, + dba_st: :kvs_stream, + schema: [:kvs, :kvs_stream] diff --git a/lib/up_nitro.ex b/lib/up_nitro.ex index 4774eb5..d03e8c5 100644 --- a/lib/up_nitro.ex +++ b/lib/up_nitro.ex @@ -1,7 +1,5 @@ defmodule UP.NITRO do - def event(:init) do - :io.format 'NITRO' - end - def event(_), do: [] + def event(:init), do: :io.format 'NITRO INIT~n' + def event(x), do: :io.format 'MESSAGE ~p~n', [x] # > direct(tuple(atom('ok'),number(2))) end diff --git a/lib/up_route.ex b/lib/up_route.ex index 47eb84a..3880278 100644 --- a/lib/up_route.ex +++ b/lib/up_route.ex @@ -1,14 +1,8 @@ defmodule UP.Route do require N2O - require Logger - def finish(state, ctx), do: {:ok, state, ctx} def init(state, context) do %{path: path} = N2O.cx(context, :req) - {:ok, state, N2O.cx(context, path: path, module: ws(path))} + {:ok, state, N2O.cx(context, path: path, module: UP.NITRO)} end - - def ws(_), do: UP.NITRO - def route(_), do: UP.NITRO - end