blob: a290653aebffa1132cbc8cdd4940603425026438 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[[OpenStack]]
---
### To JS Framework or not to JS Framework
I was in doubt whether or not to use a JavaScript framework. I conversed with Gemini about this. I gave the context that I was considering a JavaScript Framework or just using minimal JavaScript with HTML/CSS using HTMX and a Golang backend which I was leaning towards.
It confirmed my gut feeling that the latter, not using a full blown JavaScript framework, is the good option especially for learning.
So my decision: use purely HTML/CSS with HTMX and a Golang backend that drives it.
### Can I do real-time feedback?
Using SSE or WebSockets it is possible. HTMX supports this out-of-the box. We can listen for events from OpenStack and then push updates from the server to the client.
##### SSE or WebSockets?
SSE is useful when the traffic flows mostly from the server to the client. WebSockets is a full-duplex connection and thus more likely candidate when the client also converses with the server alot.
In our case I think **SSE** would be the best fit as the client mostly just listens.
#### SSE
It works by exposing an endpoint of which the connection is kept alive by the backend when a client connects to it. It can then periodically send its events over this connection.
`Content-Type` header should be set by the server to: `text/event-stream`.
`Cache-Control` set to `no-cache`. **Not yet sure why. Let's investigate.**
`Connection` set to `keepalive`. This is to ensure the connection is kept open so we can send our events.
|