From a0b4c5dea139fa5829c99de0529b2f7e14bf05a9 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Mon, 5 Jul 2010 17:00:55 -0400 Subject: move db_path logic to chttpd --- src/chttpd.erl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.2.3