starting chat service
This commit is contained in:
@@ -226,6 +226,7 @@ route(Sock, get, Route, Request) ->
|
||||
case Route of
|
||||
<<"/">> -> home(Sock);
|
||||
<<"/default.css">> -> default_css(Sock);
|
||||
<<"/chat.html">> -> chat_html(Sock);
|
||||
<<"/ws-test-echo.html">> -> ws_test_echo_html(Sock);
|
||||
<<"/ws/echo">> -> ws_echo(Sock, Request);
|
||||
_ -> http_err(Sock, 404)
|
||||
@@ -318,6 +319,19 @@ ws_test_echo_html(Sock) ->
|
||||
http_err(Sock, 500)
|
||||
end.
|
||||
|
||||
chat_html(Sock) ->
|
||||
%% fixme: cache
|
||||
Path_IH = filename:join([zx:get_home(), "priv", "chat.html"]),
|
||||
case file:read_file(Path_IH) of
|
||||
{ok, Body} ->
|
||||
Resp = #response{headers = [{"content-type", "text/html"}],
|
||||
body = Body},
|
||||
respond(Sock, Resp);
|
||||
Error ->
|
||||
io:format("~p error: ~p~n", [self(), Error]),
|
||||
http_err(Sock, 500)
|
||||
end.
|
||||
|
||||
wfcin(Sock, #request{enctype = json,
|
||||
cookies = Cookies,
|
||||
body = #{"wfcin" := Input}}) ->
|
||||
|
||||
Reference in New Issue
Block a user