diff options
author | Adam Kocoloski <adam@cloudant.com> | 2010-07-05 17:00:55 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2010-08-12 11:18:48 -0400 |
commit | a0b4c5dea139fa5829c99de0529b2f7e14bf05a9 (patch) | |
tree | a1059043ab99c444ac7fa86e8e73e43f43566504 | |
parent | 3cc7699cb3cae998ac95827e1239e76191f8c12f (diff) |
move db_path logic to chttpd
-rw-r--r-- | src/chttpd.erl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/chttpd.erl b/src/chttpd.erl index 9851c97b..9df127dd 100644 --- a/src/chttpd.erl +++ b/src/chttpd.erl @@ -64,7 +64,8 @@ handle_request(MochiReq) -> % removed, but URL quoting left intact RawUri = MochiReq:get(raw_path), Customer = cloudant_util:customer_name(#httpd{mochi_req=MochiReq}), - Path = ?COUCH:db_path(RawUri, Customer), + {Path, _, _} = mochiweb_util:urlsplit_path(generate_customer_path(RawUri, + Customer)), {HandlerKey, _, _} = mochiweb_util:partition(Path, "/"), LogForClosedSocket = io_lib:format("mochiweb_recv_error for ~s - ~p ~s", [ @@ -154,6 +155,20 @@ handle_request(MochiReq) -> couch_stats_collector:increment({httpd, requests}), {ok, Resp}. +generate_customer_path("/", _Customer) -> + ""; +generate_customer_path("/favicon.ico", _Customer) -> + "favicon.ico"; +generate_customer_path([$/,$_|Rest], _Customer) -> + lists:flatten([$_|Rest]); +generate_customer_path([$/|RawPath], Customer) -> + case Customer of + "" -> + RawPath; + Else -> + lists:flatten([Else, "%2F", RawPath]) + end. + % Try authentication handlers in order until one returns a result authenticate_request(#httpd{user_ctx=#user_ctx{}} = Req, _AuthFuns) -> Req; |