[crary PATCH] crary to pass path as second arg to handler

1 view
Skip to first unread message

Scott R Parish

unread,
Jul 2, 2008, 11:43:38 PM7/2/08
to erlwa...@googlegroups.com, Scott R Parish
---
TODO | 1 -
src/crary_ctrl.erl | 7 ++++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/TODO b/TODO
index eaf2a8b..6befbe4 100644
--- a/TODO
+++ b/TODO
@@ -58,4 +58,3 @@ potential modules:

seperate projects:
* url library
- * date library
diff --git a/src/crary_ctrl.erl b/src/crary_ctrl.erl
index 5a61d1c..1469803 100644
--- a/src/crary_ctrl.erl
+++ b/src/crary_ctrl.erl
@@ -32,6 +32,7 @@
-export([call_handler/2]).

-include("crary.hrl").
+-include("uri.hrl").

-define(OPT_DEFAULTS,
[{keep_alive_timeout, 30000}, % in milliseconds
@@ -101,11 +102,11 @@ setup_uri(#crary_req{uri = Uri} = Req) ->
UriRec = uri:from_http_1_1("http", crary_headers:get("host", Req), Uri),
Req#crary_req{uri = UriRec}.

-call_handler(Req, Handler) ->
+call_handler(#crary_req{uri = #uri{path = Path}} = Req, Handler) ->
try
case Handler of
- {M, F, Args} -> apply(M, F, [Req | Args]);
- F when is_function(F) -> F(Req);
+ {M, F, Args} -> apply(M, F, [Req, Path | Args]);
+ F when is_function(F) -> F(Req, Path);
Unknown ->
throw({crary_ctrl_error, {unknown_handler_type, Unknown}})
end
--
1.5.3.7

Reply all
Reply to author
Forward
0 new messages