3 ms·
I read some of the HTMX essays [0] last week due to it being accepted into the GitHub accelerator program. So, a fully RESTful API must output HTML. I'm not go
by codingclaws 3y ago
I read some of the HTMX essays [0] last week due to it being accepted into the GitHub accelerator program.
So, a fully RESTful API must output HTML. I'm not going to go into why but that's what Roy Fielding (the creator of REST), Martin Fowler and the HTMX guy(s) say.
The HTMX guy(s) also say that of course this fully RESTful API that outputs HTML is sometimes bad because you don't want to have to parse data out of HTML. So, the optimal setup is to have both a fully RESTful HTML API and the more common JSON API.
I also think that for the fully RESTful HTML API, it doesn't make sense for the outputted HTML to have any JS.
So, the question I'm pondering at the moment is, is a fully RESTful HTML API simply a website that doesn't use any JS? If so, then the optimal setup is to have an SSR website that doesn't use JS and a JSON API. Of course, under the hood, the website and the JSON API use the same lower level API (eg. SQL queries and back-end functions).
What's crazy for me personally is that this is exactly how I have set up Comment Castles. There's the no JS website [1] and the JSON API [2]. But I didn't build a no JS website because of REST, I just prefer websites that have no front-end JS.
[0] https://htmx.org/essays https://htmx.org/essays
[1] https://www.commentcastles.org https://www.commentcastles.org
[2] https://www.commentcastles.org/api https://www.commentcastles.org/api
- adamckay 3y ago> is a fully RESTful HTML API simply a website that doesn't use any JS? No, I don't think so. Sprinkling a little client side JS can certainly be beneficial and doesn't invalidate it being a RESTful HTML API. _hyperscript [1] was created by the htmx author for that purpose. There's a book [2] that you may not have seen written by some core htmx dev's that goes into this [3] in more detail. [1] - https://hyperscript.org/ https://hyperscript.org/ [2] - https://hypermedia.systems/ https://hypermedia.systems/ [3] - https://hypermedia.systems/client-side-scripting/ https://hypermedia.systems/client-side-scripting/