안녕하세요 저는 사용자에게 쿠키를 보내고 웹 페이지를 표시하는 웹 사이트를 만들려고합니다.Mochiweb 쿠키를 생성 한 후
그래서 http://alexmarandon.com/articles/mochiweb_tutorial/ 쿠키를 만드는 방법에 대한 유일한 실제 튜토리얼로 발견되었지만 나를 위해 오류가있는 것 같습니다.
loop(Req, DocRoot) ->
"/" ++ Path = Req:get(path),
try
case dispatch(Req, valid_urls:urls()) of
none ->
case filelib:is_file(filename:join([DocRoot, Path])) of
true ->
%% If there's a static file, serve it
Req:serve_file(Path, DocRoot);
false ->
%% Otherwise the page is not found
case Req:get(method) of
Method when Method =:= 'GET'; Method =:= 'HEAD' ->
case Path of
"response" ->
QueryStringData = Req:parse_qs(),
Username = get_username(Req, QueryStringData),
Cookie = make_cookie(Username),
FindCookie = get_cookie_value(Req,"mename","Not Found."),
% render_ok(Req, [Cookie], greeting_dtl, [{username, Username}]),
Req:respond({200, [{"Content-Type", "text/html"}],
"<html><p>Webpage</p></hmtl>"});
_ ->
Req:not_found()
end
end
end;
Response ->
Response
end
catch
Type:What ->
Report = ["web request failed",
{path, Path},
{type, Type}, {what, What},
{trace, erlang:get_stacktrace()}],
error_logger:error_report(Report),
%% NOTE: mustache templates need \ because they are not awesome.
Req:respond({500, [{"Content-Type", "text/plain"}],
"request failed, sorry\n"})
end.
오류 I :
내 루프는 다음과 같이 (I 대신 '이름'의 핵심으로 'mename'를 사용 제외하고 내 make_cookie, get_cookie_value, render_ok 및 get_username 자신과 동일하다)를 찾습니다 수는 다음과 같습니다
[error] "web request failed", path: "response", type: error, what: undef, trace: [{greeting_dtl,render,[[{username,"GET"}]],[]}
오류가 render_ok에서 오는 것 같다,하지만 얼랑 - mochiweb 새로운 것을 나는이 문제를 해결하는 방법에 대한 확실하지 않다.