Skip to content

Instantly share code, notes, and snippets.

@archaelus
Created July 5, 2009 21:06
Show Gist options
  • Select an option

  • Save archaelus/141120 to your computer and use it in GitHub Desktop.

Select an option

Save archaelus/141120 to your computer and use it in GitHub Desktop.
%% @copyright Geoff Cant
%% @author Geoff Cant <[email protected]>
%% @version {@vsn}, {@date} {@time}
%% @doc EWGI Mochiweb example app.
%% @end
-module(ewex_web).
-export([start/0,stop/0,
loop/1,app_run/1]).
start() ->
mochiweb_http:start([{name, ewex}, {loop, fun ?MODULE:loop/1},
{ip, "127.0.0.1"}, {port, 8889}]).
stop() ->
mochiweb_http:stop(ewex).
loop(Req) ->
Mod = ewgi_mochiweb:new(fun ?MODULE:app_run/1),
Mod:run(Req).
app_run({ewgi_context, Request, _Response}) ->
ResponseHeaders = [{"Content-type", "text/plain"}],
Response = {ewgi_response, {200, "OK"}, ResponseHeaders,
[<<"Hello world!">>], undefined},
{ewgi_context, Request, Response}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment