If it's JSON then name it /foo/bar.json, and as a bonus you can also have /foo/bar.html!
You say the extension is cruft. That's your opinion. I don't share it.
If it's JSON then name it /foo/bar.json, and as a bonus you can also have /foo/bar.html!
You say the extension is cruft. That's your opinion. I don't share it.
The alternative is to declare what you want on the Accept header, what is way less transparent but is more flexible.
I never saw any site where the extra flexibility added any value. So, right now I do favor the extension.
At the risk of committing the appeal-to-authority fallacy, it's also the opinion of Tim Berners-Lee, which I would hope carries at least some weight.
The way I look at it is that yes, the extension can be useful for requesting a particular file format (IMO the Accept header is not particularly accessible, especially if you are just a regular web browser user). But if you have a default/canonical representation, then you should give that representation in response to a URL that has no extension. And when you link to that document in a representation-neutral way, you should link without the extension.
That doesn't stop you from also serving that same content from a URL that includes the extension that describes the default/canonical representation. And people who want to link to you and ensure they get a particular representation can use the extension in their links. But someone who doesn't care, and just wants the document in whatever format the website owner recommends, should be able to get it without needing to know the extension. For those situations, the extension is an implementation detail that is irrelevant to most visitors.
> it's also the opinion of Tim Berners-Lee, which I would hope carries at least some weight
Not at all. He's famous for helping create the initial version of JavaScript, which was a fairly even mixture of great and terrible. Which means his initial contributions to software were not extremely noteworthy, and he just happened to be in the right time and right place, since something like JavaScript was apparently inevitable. Plus, I can't think of any of his major contributions to software in the decades since. So no, I don't even think that's really an appeal to authority.
> [Tim Berners-Lee is] famous for helping create the initial version of JavaScript
You may be thinking of Brendan Eich? Berners-Lee is famous for HTML, HTTP, the first web browser, and the World Wide Web in general; as far as I know he had nothing to do with JS.