couchdb - How to get a couchapp to serve a file with no extension (implied .html) -
i have couchapp working fine.
this works: http://domain.com/file.html
not: http://domain.com/file
i want understand if there no extension, should try .html extension.
i'm not sure if _rewrite rule (which using prettify urls) or else.
afaik rewrites cannot used add suffix matched variable in url path.
an alternative approach use put content of file.html document id "file" under given key (named "content" or similar), create show function [1] (calling "render") outputs value of key content type "text/html" , create rewriter such as:
{ "from": "/:doc", "to": "/_show/render/:doc", "method": "get", "query": { } }
the complete design doc this:
{ "_id": "_design/rewrite", "shows": { "render": "function(doc) { return { headers: { \"content-type\": \"text/html\"}, body: doc.content } }" }, "rewrites": [ { "query": {}, "method": "get", "to": "/_show/render/:doc", "from": "/:doc" } ] }
and corresponding doc:
{ "_id": "file", "content": "<html>html content of doc goes here</html>" }
i've shared example follows above pattern [2].
[1] http://wiki.apache.org/couchdb/formatting_with_show_and_list
[2] https://mikewallace.cloudant.com/rewriter/_design/rewrite/_rewrite/file
Comments
Post a Comment