Current section

Files

Jump to
mad priv web apps sample src routes.erl
Raw

priv/web/apps/sample/src/routes.erl

-module(routes).
-author('Maxim Sokhatsky').
-include_lib("n2o/include/wf.hrl").
-export([init/2, finish/2]).
finish(State, Ctx) -> {ok, State, Ctx}.
init(State, Ctx) ->
Path = wf:path(Ctx#cx.req),
wf:info(?MODULE,"Route: ~p~n",[Path]),
{ok, State, Ctx#cx{path=Path,module=route_prefix(Path)}}.
route_prefix(<<"/ws/",P/binary>>) -> route(P);
route_prefix(<<"/",P/binary>>) -> route(P);
route_prefix(P) -> route(P).
route(<<>>) -> index;
route(<<"index">>) -> index;
route(<<"favicon.ico">>) -> static_file;
route(<<"static/spa/index.htm">>) -> index;
route(_) -> index.