diff options
author | Joel Reed <joelwreed@gmail.com> | 2011-01-31 09:25:02 -0500 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2012-11-14 20:47:37 +0100 |
commit | 2774531ff2946c0155dc6cb2af153e6378c41963 (patch) | |
tree | 079170ced3ccaf79d290ee1b2e5832bca4626360 | |
parent | c6252d6d7f8d7fa3a27bf8e09beecb87033fa2fa (diff) | |
download | couchdb-2774531ff2946c0155dc6cb2af153e6378c41963.tar.gz |
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
-rw-r--r-- | src/couchdb/couch_httpd_misc_handlers.erl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl index 2150bea62..c884271f0 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 |