sideshowcoder / canned

Server to respond with fake API responses, by using a directory of files for finding out what to say!
213 stars 46 forks source link

Default error message #22

Open runemadsen opened 10 years ago

runemadsen commented 10 years ago

Most API's have a default error message like this:

{"message":"404 Not found"}

It would be awesome if we could create a 404.json or something, and have a default error response from canned. Any thoughts on name and other functionality? I might take a stab at this soon.

sideshowcoder commented 10 years ago

Sounds good, I would follow you approach of using 'special' files like 404.json for this. Wondering if there is a way to support multiple formats like xml, html, and json. Probably the best is going for a detection via the Accept header and if this fails try to match a content type from the request URL since there are enough cases where setting the content type is done via adding .json to the URL (looking at you rails ;) ).

They fallback should be HTML still I think. So maybe we can even include something helpful by default then if not overwritten by the user.