Skip to content

Commit

Permalink
Add couch_httpd_misc_handlers:handle_file_req
Browse files Browse the repository at this point in the history
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
joelwreed authored and janl committed Nov 14, 2012
1 parent c6252d6 commit 2774531
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/couchdb/couch_httpd_misc_handlers.erl
Expand Up @@ -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
Expand Down

0 comments on commit 2774531

Please sign in to comment.