4 ms·
I interrupted my reading at 'Accept and respond with JSON' to write this comment, before I skipped over that section and returned to reading the rest. Folks th
by seliopou 6y ago
I interrupted my reading at 'Accept and respond with JSON' to write this comment, before I skipped over that section and returned to reading the rest.
Folks that aren't aware of Webmachine should take a look:
https://github.com/webmachine/webmachine https://github.com/webmachine/webmachine
The 'Accept' header should determine the response type, but content negotiation is something that few bother to implement. Webmachine does that for you, among other things like choosing the correct status code for your response.
Also, shameless plug for my OCaml port:
https://github.com/inhabitedtype/ocaml-webmachine https://github.com/inhabitedtype/ocaml-webmachine
- dmitriid 6y ago> The 'Accept' header should determine the response type Also, the HTTP decision diagram: https://github.com/for-GET/http-decision-diagram/tree/master/doc https://github.com/for-GET/http-decision-diagram/tree/master...
- Longwelwind 6y agoWhat is the usefulness of this feature? The only advantage I see is that your clients can choose the format they want to work with, but since the serialization format is just a message format that has no impact on the code, and that most of them have a bijective transformation between them, I don't see the point. If it feels like a lot of work (Or the added complexity of a moving part, if using the tool you linked) for next to no impact.
- dec0dedab0de 6y agothings like this are useful if you have a user that is integrating your api into some kind of legacy application that does not support json. Then in the future when JSON goes out of style, you could easily add support whatever the new format is.
- pionar 6y agoIf you don't care about others using your API, then don't do it. If you do, follow the standard which says you SHOULD have a Content-Type if there is a body to your response.
- Longwelwind 6y agoMy comment was about whether it's worth supporting multiple values for the "Accept" header, not the "Content-Type" header.
- trevor-e 6y agoI've read through the README and links and still have no idea what webmachine does.
- spelunker 6y ago> Webmachine is an application layer that adds HTTP semantic awareness on top of the excellent bit-pushing and HTTP syntax-management provided by mochiweb, and provides a simple and clean way to connect that to your application's behavior. Great buzzwords, I have no idea what this project actually does.
- capableweb 6y agoIt's less buzzwords and more that you're required to understand HTTP and probably be a programmer to understand what's being said. For you and other non-programmers: https://tools.ietf.org/id/draft-ietf-httpbis-semantics-03.html https://tools.ietf.org/id/draft-ietf-httpbis-semantics-03.ht... (particularly https://tools.ietf.org/id/draft-ietf-httpbis-semantics-03.html#rfc.section.6.4 https://tools.ietf.org/id/draft-ietf-httpbis-semantics-03.ht...) Also knowing that mochiweb is a library for doing HTTP servers would help. Once you've learned these two, the sentence immediately becomes clear, what Webmachine is aiming for. I think this happens quite often when you're dealing with a lot of domains you don't understand. I'm not a doctor, so when doctors talk, it can sound like mumbo-jumbo, but I'm sure it makes sense for them, since they are professionals.
- Toutouxc 6y ago> For you and other non-programmers > Once you've learned these two, the sentence immediately becomes clear > it can sound like mumbo-jumbo, but I'm sure it makes sense for them, since they are professionals Did you just link a person to a two-kilometer long page about HTTP, assumed they're not a programmer and almost accused them of not being professional enough, because they haven't heard of some Erlang library? > application layer that adds HTTP semantic awareness on top of the excellent bit-pushing and HTTP syntax-management I'm a web developer and my reaction was exactly the same. What the heck does this thing actually do?
- capableweb 6y ago> Did you just link a person to a two-kilometer long page about HTTP, assumed they're not a programmer and almost accused them of not being professional enough, because they haven't heard of some Erlang library? Nope, I linked to a specific section of a HTTP specification that goes through "Content Negotiation" since that was what the topic was about and I wanted to share a resource to spelunker so they could read more about it, as if you're familiar with the topic, what seliopou wrote is not alien.
- dec0dedab0de 6y agoDjango REST Framework has this built in, and is very easy to turn on. I always turn it on even though my users almost exclusively use json. I had one user use xml once, because they didnt know how to use json in whatever it was they were using. Noone has ever used yaml, but i leave it there just in case. if you do it right, using the standard html content type returns a human browseable representation of your api with forms for posts and whatnot.
- NanoWar 6y agoOmg I love the browsable api of Django. I am searching for something similar for .NET - any pointers anyone?