Commits

Fred T-H committed ead757f

adding support for history, server-side

Comments (0)

Files changed (1)

src/web_server.erl

 
 handle("/history", Req) ->
     Params = Req:parse_qs(),
-    reply(Req, mochijson2:encode(ok), Params);
+    Nick = proplists:get_value("id",Params),
+    {ok, Handler} = client:connect(Nick),
+    Msgs = client:history(Nick),
+    JSON = mochijson2:encode([json_prepare(M) || M <- Msgs]),
+    client:disconnect(Nick, Handler),
+    reply(Req, JSON, Params);
 
 handle(Path, Req) ->
     Params = Req:parse_qs(),