-module(n2o_sample_app). -behaviour(application). -export([ start/2, stop/1 ]). -export([ routes/0, update_routes/0 ]). -define(MIME, [{mimetypes, cow_mimetypes, all}]). update_routes() -> Dispatch = routes(), cowboy:set_env(http, dispatch, Dispatch). %-define(STATIC, { dir, "apps/n2o_sample/priv", ?MIME }). -define(STATIC1, { dir, "apps/n2o_sample/priv/static", ?MIME }). -define(STATIC2, { dir, "apps/n2o_sample/priv/js", ?MIME }). -define(STATIC3, { dir, "apps/n2o_sample/priv/css", ?MIME }). %-define(STATIC_N4U, { dir, "deps/n4u/priv", ?MIME }). routes() -> cowboy_router:compile([{'_', [ {"/static/[...]", n2o_static, ?STATIC1}, %% static without nginx by cowboy % todo : clean - mv to stc folder {"/js/[...]", n2o_static, ?STATIC2}, %% static without nginx by cowboy {"/css/[...]", n2o_static, ?STATIC3}, %% static without nginx by cowboy {"/img/[...]", n2o_static, ?STATIC1}, %% static without nginx by cowboy %{"/static/[...]", n2o_static, ?STATIC}, %% static without nginx by cowboy % todo : clean - mv to stc folder %{"/js/[...]", n2o_static, ?STATIC}, %% static without nginx by cowboy %{"/css/[...]", n2o_static, ?STATIC}, %% static without nginx by cowboy %{"/img/[...]", n2o_static, ?STATIC}, %% static without nginx by cowboy % {"/n4u/[...]", n2o_static, ?STATIC_N4U},%% static without nginx by cowboy {"/multipart/[...]", n2o_multipart, []}, {"/rest/:resource", rest_cowboy, []}, {"/rest/:resource/:id", rest_cowboy, []}, {"/ws/[...]", n2o_stream, []}, {'_', n2o_cowboy, []} ]}]). %start() -> start(normal,[]). start(_,_) -> %%[application:start(A) || A <- [asn1,kernel,stdlib,fs,ranch,compiler,syntax_tools,mnesia,crypto,inets,kvs,public_key,ssl,cowboy,n4u,n4u_sample,active,avz,epgsql,pooler,epgsql_pool,erlydtl,gproc,jsone,mad,nitro,oauth,rest,sh] ], %[application:start(A) || A <- [asn1,kernel,stdlib,fs,compiler,syntax_tools,mnesia,crypto,inets,kvs,public_key,ssl,ranch,cowboy,n4u,active,avz,epgsql,pooler,epgsql_pool,erlydtl,gproc,jsone,mad,nitro,oauth,rest,sh] ],% todo fix rest on erl24 [application:start(A) || A <- [asn1,kernel,stdlib,fs,compiler,syntax_tools,mnesia,crypto,inets,kvs,public_key,ssl,ranch,cowboy,n4u,active,avz,epgsql,pooler,epgsql_pool,erlydtl,gproc,jsone,mad,nitro,oauth,sh] ], {ok, _} = application:ensure_all_started(ranch), {ok, _} = application:ensure_all_started(cowboy), n2o_sample_sup:start_link(). stop(_) -> ok.