You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2012/11/14 20:47:19 UTC

git commit: Add couch_httpd_misc_handlers:handle_file_req

Updated Branches:
  refs/heads/master c6252d6d7 -> 2774531ff


Add couch_httpd_misc_handlers:handle_file_req

This can be used to serve up files like /crossdomain.xml from a
CouchDB instance. For example, you could add:

    [httpd_global_handlers]
    crossdomain.xml = {couch_httpd_misc_handlers, handle_file_req, "/usr/share/couchdb/www/crossdomain.xml" }

To your local.ini to serve up crossdomain.xml.

Closes #4


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/2774531f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2774531f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2774531f

Branch: refs/heads/master
Commit: 2774531ff2946c0155dc6cb2af153e6378c41963
Parents: c6252d6
Author: Joel Reed <jo...@gmail.com>
Authored: Mon Jan 31 09:25:02 2011 -0500
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Wed Nov 14 20:47:37 2012 +0100

----------------------------------------------------------------------
 src/couchdb/couch_httpd_misc_handlers.erl |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/2774531f/src/couchdb/couch_httpd_misc_handlers.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index 2150bea..c884271 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -57,6 +57,12 @@ handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) ->
 handle_favicon_req(Req, _) ->
     send_method_not_allowed(Req, "GET,HEAD").
 
+handle_file_req(#httpd{method='GET'}=Req, Document) ->
+    couch_httpd:serve_file(Req, filename:basename(Document), filename:dirname(Document));
+
+handle_file_req(Req, _) ->
+    send_method_not_allowed(Req, "GET,HEAD").
+
 handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
     "/" ++ UrlPath = couch_httpd:path(Req),
     case couch_httpd:partition(UrlPath) of