couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nsla...@apache.org
Subject [4/30] git commit: Add couch_httpd_misc_handlers:handle_file_req
Date Sat, 17 Nov 2012 19:52:49 GMT
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/docs
Commit: 2774531ff2946c0155dc6cb2af153e6378c41963
Parents: c6252d6
Author: Joel Reed <joelwreed@gmail.com>
Authored: Mon Jan 31 09:25:02 2011 -0500
Committer: Jan Lehnardt <jan@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


Mime
View raw message