News for hackers. Stuff that matters.
Re:Why I Tend Not to Use Content Negotiation by Gigachad on Monday November 20, 2023 @03:07AM (#38344338)
The only time you'd ever want to do this is for image and video formats. And HTML has built in support for this in the picture and video tags. Otherwise this sounds nonsensical.

What kind of situation would you ever have a request like "Uh I want json the most but XML could work". Either the backend serves it in a format or not, just directly request what you want.

Re:Why I Tend Not to Use Content Negotiation by naasking on Tuesday November 21, 2023 @12:18AM (#38359644)
XML, JSON, Protobuf can all be used as object serialization formats. It's not nonsensical at all for an endpoint to offer choice as to what serialization format a client may want to use. It's not common, but that doesn't mean nonsensical.
Re:Why I Tend Not to Use Content Negotiation by Gigachad on Tuesday November 21, 2023 @02:54AM (#38360689)
The client can request the URL that gets the type of response it wants. There is no advantage of using the accept header.
Re:Why I Tend Not to Use Content Negotiation by naasking on Tuesday November 21, 2023 @08:03AM (#38363108)
URLs are much longer, harder to remember and harder to communicate than accept header values. It also unnecessarily complicates the API. Seems like there are more than one advantage.