Created
July 16, 2009 13:04
-
-
Save filippo/148396 to your computer and use it in GitHub Desktop.
ewgi middleware example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loop(Req, DocRoot) -> | |
Mod = ewgi_mochiweb:new(fun ?MODULE:simple_stack/1), | |
Mod:run(Req). | |
simple_stack(Ctx) -> | |
to_upper(hello_app(Ctx)). | |
hello_app({ewgi_context, Request, _Response}) -> | |
ResponseHeaders = [{"Content-type", "text/plain"}], | |
Response = {ewgi_response, {200, "OK"}, ResponseHeaders, | |
[<<"Hello world!">>], undefined}, | |
{ewgi_context, Request, Response}. | |
to_upper({ewgi_context, Request, Response}=Ctx) -> | |
Body = ewgi_api:response_message_body(Ctx), | |
Body1 = [string:to_upper(erlang:binary_to_list(B)) || B <- Body], | |
ewgi_api:response_message_body(Body1, Ctx). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment