3 ms·
Why? HTML is just another output format for a resource. Like Json or Xml.
by MatthewPhillips 14y ago
Why? HTML is just another output format for a resource. Like Json or Xml.
- mattetti 14y ago@MatthewPhillips maybe because the logic to generate JSON and HTML is very often quite different and having a tight coupling at this level might result in some serious pains later on.
- MatthewPhillips 14y agoHow are they tightly coupled? You take the same data and either run it through a Json serializer or a view renderer.
- mattetti 14y ago> You take the same data and either run it through a Json serializer or a view renderer. My experience might be different than yours, but very often my html views quickly end up needed more than 1 resource to render and now I need to fetch data just for the html templates. The same data set isn't needed when returning json or xml and the API end points exposed for data consumption are often quite different. That said, in some cases, I agree that your approach would work.
- tapajos 14y ago@MatthewPhillips, In the real world the HTML output is not like JSON or XML as you told. It is used to show data to a human and most of the time it contains a lot of elements that are not related with the resource data even if it is not representing more than a resource in the same page. The interaction with a human doesn't happen in the same way as with another system.