From 1326c40d66563279dcce712f130c10e5d1d80a03 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Fri, 19 Dec 2008 08:25:19 +0000 Subject: shorter path to _action servers, external supports better routing control git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@727973 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_external.erl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/couchdb/couch_httpd_external.erl') diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl index 7ed3d51a..84f1c444 100644 --- a/src/couchdb/couch_httpd_external.erl +++ b/src/couchdb/couch_httpd_external.erl @@ -12,7 +12,7 @@ -module(couch_httpd_external). --export([handle_external_req/2]). +-export([handle_external_req/2, handle_external_req/3]). -import(couch_httpd,[send_error/4]). @@ -25,10 +25,9 @@ headers = [] }). -handle_external_req(#httpd{mochi_req=Req, - method=Verb, - path_parts=[_DbName, _External, UrlName | Path] - }=HttpReq, Db) -> +process_external_req(#httpd{mochi_req=Req, + method=Verb + }=HttpReq, Db, Name, Path) -> ReqBody = Req:recv_body(), ParsedForm = case Req:get_primary_header_value("content-type") of "application/x-www-form-urlencoded" ++ _ -> @@ -36,7 +35,7 @@ handle_external_req(#httpd{mochi_req=Req, _ -> [] end, - Response = couch_external_manager:execute(binary_to_list(UrlName), + Response = couch_external_manager:execute(binary_to_list(Name), Db, Verb, Path, Req:parse_qs(), ReqBody, ParsedForm, Req:parse_cookie()), @@ -45,12 +44,22 @@ handle_external_req(#httpd{mochi_req=Req, send_error(HttpReq, 404, <<"external_server_error">>, Msg); _ -> send_external_response(Req, Response) - end; + end. + +handle_external_req(#httpd{ + path_parts=[_DbName, _External, UrlName | Path] + }=HttpReq, Db) -> + process_external_req(HttpReq, Db, UrlName, Path); handle_external_req(#httpd{path_parts=[_, _]}=Req, _Db) -> send_error(Req, 404, <<"external_server_error">>, <<"No server name specified.">>); handle_external_req(Req, _) -> send_error(Req, 404, <<"external_server_error">>, <<"Broken assumption">>). +handle_external_req(#httpd{ + path_parts=[_DbName, _External | Path] + }=HttpReq, Db, Name) -> + process_external_req(HttpReq, Db, Name, Path). + send_external_response(Req, Response) -> #extern_resp_args{ code = Code, -- cgit v1.2.3