You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by 7zark7 <7z...@gmail.com> on 2010/04/20 05:04:30 UTC

Customize 404 response?

Hi,

I was wondering if there is a way to return html content for 404 errors, 
instead of the default json:

HTTP/1.1 404 Object Not Found
Server: CouchDB/0.11.0 (Erlang OTP/R13B)
Date: Tue, 20 Apr 2010 02:58:22 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 41
Cache-Control: must-revalidate

{"error":"not_found","reason":"missing"}


Thanks

Re: Customize 404 response?

Posted by Anh <7z...@gmail.com>.
On Tue, Apr 20, 2010 at 9:36 AM, David Coallier
<da...@gmail.com> wrote:
>>
>> Would it be doable with a web server in front of couchdb ?
>>
>
> You could easily catch the messages and have a custom 40x status code
> if you put a proxy/webserver in front of your Couch yes.
>
> --
> David Coallier
>

Yes, though that is what I'm trying to ditch in favor of CouchDB-only
solution :-)
We have a hardware proxy, I'll see if I could catch it there.

Thanks

Re: Customize 404 response?

Posted by David Coallier <da...@gmail.com>.
>
> Would it be doable with a web server in front of couchdb ?
>

You could easily catch the messages and have a custom 40x status code
if you put a proxy/webserver in front of your Couch yes.

-- 
David Coallier

Re: Customize 404 response?

Posted by Mirsal Ennaime <mi...@gmail.com>.
On Tue, Apr 20, 2010 at 5:58 PM, J Chris Anderson <jc...@gmail.com> wrote:
> This isn't possible in a general way. The CouchDB API is JSON based.

Would it be doable with a web server in front of couchdb ?

-- 
Mirsal

Re: Customize 404 response?

Posted by Anh <7z...@gmail.com>.
On Tue, Apr 20, 2010 at 8:58 AM, J Chris Anderson <jc...@gmail.com> wrote:
>
> On Apr 19, 2010, at 8:04 PM, 7zark7 wrote:
>
>> Hi,
>>
>> I was wondering if there is a way to return html content for 404 errors, instead of the default json:
>>
>
> This isn't possible in a general way. The CouchDB API is JSON based.
>
> However, you can return custom 404s from a _show or _list function.
>
> http://books.couchdb.org/relax/design-documents/shows
>

Thanks Chris, I hadn't thought of that.

Though my current project involves working with a document's attachments,
and it seems show functions are unable to return the binary data for
attachments.  (Which includes images, videos, etc)

The only way I've been able to serve the attachment is via direct GET
request, or using the rewrite functionality.

Is my understanding correct?


Thanks




>> HTTP/1.1 404 Object Not Found
>> Server: CouchDB/0.11.0 (Erlang OTP/R13B)
>> Date: Tue, 20 Apr 2010 02:58:22 GMT
>> Content-Type: text/plain;charset=utf-8
>> Content-Length: 41
>> Cache-Control: must-revalidate
>>
>> {"error":"not_found","reason":"missing"}
>>
>>
>> Thanks
>
>

Re: Customize 404 response?

Posted by J Chris Anderson <jc...@gmail.com>.
On Apr 19, 2010, at 8:04 PM, 7zark7 wrote:

> Hi,
> 
> I was wondering if there is a way to return html content for 404 errors, instead of the default json:
> 

This isn't possible in a general way. The CouchDB API is JSON based.

However, you can return custom 404s from a _show or _list function.

http://books.couchdb.org/relax/design-documents/shows

> HTTP/1.1 404 Object Not Found
> Server: CouchDB/0.11.0 (Erlang OTP/R13B)
> Date: Tue, 20 Apr 2010 02:58:22 GMT
> Content-Type: text/plain;charset=utf-8
> Content-Length: 41
> Cache-Control: must-revalidate
> 
> {"error":"not_found","reason":"missing"}
> 
> 
> Thanks