2 ms·
What you are trying to do is called "content negotiation", afaik (https://en.wikipedia.org/wiki/Content_negotiation https://en.wikipedia.org/wiki/Content_negoti
by sandreas 8y ago
What you are trying to do is called "content negotiation", afaik (https://en.wikipedia.org/wiki/Content_negotiation https://en.wikipedia.org/wiki/Content_negotiation). Perhaps you find more information about it, when you use this term.
I like the header approach, because it is nice and clean and it can be applied easily to an xhr abstraction in JavaScript, without much change.
But to make a resource absolutely idempotent in a more expressive way (which would be nice), you could also use a file-extension-like apporach:
http://host:port/database/document.json http://host:port/database/document.json
or use a parameter-based one:
http://host:port/database/document?format=json http://host:port/database/document?format=json