5 ms·
One topic I haven’t seen discussed yet is that an SPA style web app doesn’t just have JSON-API endpoints for itself but also for external systems, like an iOS a
by niels_bom 4y ago
One topic I haven’t seen discussed yet is that an SPA style web app doesn’t just have JSON-API endpoints for itself but also for external systems, like an iOS app. When using HTMX or similar systems you’d have to create 2 end points for a certain bit of functionality: one that sends HTML and another that sends JSON.
- joshlemer 4y agoMight be able to do this with a relatively simple header based middle ware which alternatively returns html or just the data injected into the view
- niels_bom 4y agoAfter browsing the book: they do touch upon this and their take is that these are 2 different things with different requirements and should be built relatively separately: https://hypermedia.systems/book/json-data-apis/ https://hypermedia.systems/book/json-data-apis/
- jmull 4y agoThat makes sense to me... I do think there would often be significant common parts between an htmx endpoint and json data endpoint, so to me it makes sense to implement these in a way where they can share common code or be built on a common layer.
- arcbyte 4y agoUsing Java microservices I have only a single endpoint per use case that returns different representations based on what is requested by the user agent. If its a browser it will request HTML and I use some simple Mustache libraries to format the HTML output. If json is requested then the built in json serialized does its thing. It feels quite elegant. I think there's room for some kind of automatic HTML serializer as well. Where styling can then be done directly in CSS.