rmsrob / simple-server-sent-event

Open a SSE connection and get a response message with it's formatted time when hit an endpoint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WIP

Go Reference Go Report Card Coverage Status Contribute with Gitpod

simple-server-sent-event

Open a SSE connection and get a response message with its formatted time when hit an endpoint

Install

Prerequisite

Note

Required:

git clone git@github.com:rrobrms/simple-server-sent-event.git
cd simple-server-sent-event
go mod tidy         # to download modules

Usage

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!

About

Open a SSE connection and get a response message with it's formatted time when hit an endpoint

License:Apache License 2.0


Languages

Language:Go 100.0%