2013-05-21 2 views
0

으로 파일을 제공하기 위해 couchapp을 얻을하는 방법.확장자 (묵시적 .html)을 내가 잘 작동됩니다 couchapp이

이 작동 : http://domain.com/file.html
이되지 않습니다 http://domain.com/file

나는 그것이 확장자가없는 경우, 그것은 .html 중에서 확장을 시도해야 이해합니다. 이 (내 URL을 값 싸게 치장을 사용하고 있습니다) 또는 다른 뭔가 _rewrite 규칙이있는 경우

는 잘 모르겠어요.

답변

3

AFAIK 재 작성은 현재 URL 경로에 일치하는 변수에 접미사를 추가 할 수 없습니다.

당신이 사용할 수있는 또 다른 접근법은 주어진 키 ("content"또는 유사) 아래에 id가 "file"인 문서에 file.html의 내용을 넣고 show function [1]을 콘텐츠 형식이 "text/html로"와 해당 키의 값을 출력하는) "렌더링"다음 라이터를 만들 같은 같은 :

{ 
    "from": "/:doc", 
    "to": "/_show/render/:doc", 
    "method": "GET", 
    "query": { 
    } 
} 

전체 설계 문서는 다음과 같이 보일 것이다 :

{ 
    "_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" 
    } 
    ] 
} 

그리고 해당 문서 :

,
{ 
    "_id": "file", 
    "content": "<html>html content of doc goes here</html>" 
} 

위의 패턴 [2]을 따르는 예가 나와 있습니다.

[1] http://wiki.apache.org/couchdb/Formatting_with_Show_and_List

[2] https://mikewallace.cloudant.com/rewriter/_design/rewrite/_rewrite/file

+0

완벽한 - 감사합니다! –