Open a SSE connection and get a response message with its formatted time when hit an endpoint
Note
Required:
git clone git@github.com:rrobrms/simple-server-sent-event.git
cd simple-server-sent-event
go mod tidy # to download modules
Start the server
go run cmd/main.go
Init the sse connection with an "keep-alive" header
- GET the endpoint
http://localhost:1323/listener
Then when you hit the desired endpoint, we can compute the message
- GET on the endpoint
http://localhost:1323/event
Cleanned logs
⇨ http server started on [::]:1323
Client connected
data: 08-04-2023 23:59:25 CEST - Hello, world!
Client connected
data: 08-04-2023 23:59:36 CEST - Hello, world!
Client connected
data: 08-04-2023 23:59:57 CEST - Hello, world!
Client connected
data: 09-04-2023 00:00:12 CEST - Hello, world!