summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_external.erl
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2008-12-19 08:25:19 +0000
committerJohn Christopher Anderson <jchris@apache.org>2008-12-19 08:25:19 +0000
commit1326c40d66563279dcce712f130c10e5d1d80a03 (patch)
tree587485404908ad79321556a2119cc92212bf1ac0 /src/couchdb/couch_httpd_external.erl
parent2a6ad51f1acd4cae30a6e976d00444a1a6931702 (diff)
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
Diffstat (limited to 'src/couchdb/couch_httpd_external.erl')
-rw-r--r--src/couchdb/couch_httpd_external.erl23
1 files changed, 16 insertions, 7 deletions
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,