[bknr-cvs] hans changed trunk/

BKNR Commits bknr at bknr.net
Fri Jul 18 16:29:16 UTC 2008


Revision: 3509
Author: hans
URL: http://bknr.net/trac/changeset/3509

Already works a little.

U   trunk/projects/pch/src/pch.erl
_U  trunk/thirdparty/mochiweb/doc/
_U  trunk/thirdparty/mochiweb/ebin/

Modified: trunk/projects/pch/src/pch.erl
===================================================================
--- trunk/projects/pch/src/pch.erl	2008-07-18 16:11:06 UTC (rev 3508)
+++ trunk/projects/pch/src/pch.erl	2008-07-18 16:29:16 UTC (rev 3509)
@@ -2,20 +2,23 @@
 %%% http://www.rsaccon.com/2007/09/mochiweb-erlang-based-webserver-toolkit.html
 
 -module(pch).
--export([start/0, loop/2, stop/0]).
+-export([start/0, loop/1, stop/0]).
 -define(DEFAULTS, [{name, ?MODULE},
-                   {port, 9952}]).
+                   {port, 9888}]).
 
 start() ->
-    DocRoot = filename:dirname(filename:dirname(code:which(?MODULE))),
-    code:add_patha(filename:join([DocRoot, "mochiweb-c4", "ebin"])),
-    Loop = fun (Req) -> ?MODULE:loop(Req, DocRoot) end,
+    Loop = fun (Req) -> ?MODULE:loop(Req) end,
     mochiweb_http:start([{loop, Loop} | ?DEFAULTS]).
 
 stop() ->
     mochiweb_http:stop(?MODULE).
 
-loop(Req, DocRoot) ->
+backend_request(Req) ->
+    {ok, {{_Version, 200, _ReasonPhrase}, Headers, Body}} =
+        http:request("http://test.createrainforest.org" ++ Req:get(path)),
+    Req:respond({200, Headers, Body}).
+
+loop(Req) ->
     "/" ++ Path = Req:get(path),
     case Req:get(method) of
         M when M =:= 'GET'; M =:= 'HEAD' ->
@@ -31,8 +34,10 @@
                 "dump" ->
                     Req:ok({"text/plain",
                             io_lib:format("~p~n", [Req:dump()])});
+%%                 _ ->
+%%                     Req:serve_file(Path)
                 _ ->
-                    Req:serve_file(Path, DocRoot)
+                    backend_request(Req)
             end;
         _ ->
             Req:respond({501, [], ""})


Property changes on: trunk/thirdparty/mochiweb/doc
___________________________________________________________________
Name: svn:ignore
   + *.html



Property changes on: trunk/thirdparty/mochiweb/ebin
___________________________________________________________________
Name: svn:ignore
   + *.beam
*.app





More information about the Bknr-cvs mailing list