Permalink
Browse files

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
  • Loading branch information...
1 parent c6252d6 commit 2774531ff2946c0155dc6cb2af153e6378c41963 @joelwreed joelwreed committed with janl Jan 31, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 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

0 comments on commit 2774531

Please sign in to comment.