I'd think this would work:
function(doc, req) {
if(doc) {
// regular doc display logic
} else { // document not found
if(req.docId) {
return { 'code': 404, 'body': 'Page not found!'});
} else {
// handle unspecified doc id
}
}
}
On Thu, Sep 24, 2009 at 6:15 PM, Aaron Quint <[email protected]> wrote:
> Interesting. Can you actually return an HTTP 404 response code though?
> --AQ
>
> Aaron Quint
> http://www.quirkey.com
>
>
>
> On Thu, Sep 24, 2009 at 6:51 PM, Chris Anderson <[email protected]> wrote:
>> heh I guess it's already done :)
>>
>> On Thu, Sep 24, 2009 at 3:38 PM, Zachary Zolton
>> <[email protected]> wrote:
>>> My apologies! I just re-read the wiki and saw my answer:
>>>
>>> function(doc, req) {
>>> if(doc) {
>>> // regular doc display logic
>>> } else { // document not found
>>> if(req.docId) {
>>> // HANDLE MISSING DOC HERE!!
>>> } else {
>>> // handle unspecified doc id
>>> }
>>> }
>>> }
>>>
>>> RTFM-FTW! :^P
>>>
>>> On Thu, Sep 24, 2009 at 3:31 PM, Chris Anderson <[email protected]> wrote:
>>>> On Thu, Sep 24, 2009 at 12:27 PM, Zachary Zolton
>>>> <[email protected]> wrote:
>>>>> Guys,
>>>>>
>>>>> Does CouchDB provide any hooks for me to execute some custom logic
>>>>> when a _show request points to non-existent docid?
>>>>>
>>>>
>>>> The problem with opening this up is that if devs are naive they might
>>>> end up treating 404s and cases where no docid was specified as the
>>>> same.
>>>>
>>>> Probably that's not a big deal. Count me as in favor of exploring an
>>>> API like you suggest.
>>>>
>>>>> Otherwise, I'm guessing it'd be best just to hack around this in my
>>>>> nginx proxy...
>>>>>
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Zach
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Chris Anderson
>>>> http://jchrisa.net
>>>> http://couch.io
>>>>
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>