求推荐Erlang的HTTP框架,目前用的Misultin,另外有关于Misultin的使用问题


而且在使用Misultin的时候对参数的处理应该怎么做?目前的做法感觉很臃肿,我该如何处理参数的异常?

handle('GET', ["datalock", "checkall"], Req) ->
    Args = Req:parse_qs(),
    case {Req:get_variable("keys", Args), Req:get_variable("user", Args), Req:get_variable("callback", Args)} of
        {undefined, _, _} ->
            Req:ok([{"Content-Type", "text/plain"}], "error param.");
        {_, undefined, _} ->
            Req:ok([{"Content-Type", "text/plain"}], "error param.");
        {_, _, undefined} ->
                Req:ok([{"Content-Type", "text/plain"}], "error param.");
        {Keys, User, Callback} ->
            case checkIds(Keys, User) of
                {ok, Result} -> 
                    Req:ok([{"Content-Type", "application/json;charset=utf-8"}], Callback++"("++Result++")")
            end
    end;

erlang

星界拉菲露 10 years, 7 months ago

mochiweb挺好的啊

狂放不羁爱奶妈 answered 10 years, 7 months ago

Your Answer