Skip to content

omjikush09/pub-sub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

pub-sub

An in-memory publish-subscribe broker via HTTP and Server-Sent Events (SSE), written in Go with no external dependencies.

Prerequisites

  • Go 1.25+

Usage

go run main.go

Server listens on :8000.

API

Publish

Publish a message to a topic.

POST /publish?topic=<topic>
Content-Type: text/plain

<message payload>

Example:

curl -X POST "http://localhost:8000/publish?topic=news" -d "Hello, World!"
# => ok

Subscribe

Subscribe to a topic via SSE. The connection stays open and streams messages as they arrive.

GET /subscribe?topic=<topic>

Example:

curl -N "http://localhost:8000/subscribe?topic=news"
# => data: Hello, World!

Project Structure

.
├── go.mod       # Go module definition
├── main.go      # Broker, subscriber, message types, HTTP handlers, and entrypoint
└── README.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages