https://github.com/mojocn/sseread
A tidy library seamlessly reads Server-Sent Events (SSE) from the response body of Go's standard HTTP package.
https://github.com/mojocn/sseread
go golang server-sent-event sse sse-client
Last synced: about 2 months ago
JSON representation
A tidy library seamlessly reads Server-Sent Events (SSE) from the response body of Go's standard HTTP package.
- Host: GitHub
- URL: https://github.com/mojocn/sseread
- Owner: mojocn
- License: apache-2.0
- Created: 2024-03-15T08:32:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-20T09:57:09.000Z (over 1 year ago)
- Last Synced: 2025-04-02T16:12:08.861Z (3 months ago)
- Topics: go, golang, server-sent-event, sse, sse-client
- Language: Go
- Homepage: https://pkg.go.dev/github.com/mojocn/sseread#pkg-index
- Size: 43 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Server Sent Events Reader
[](https://pkg.go.dev/github.com/mojocn/sseread?tab=doc)
[](https://goreportcard.com/report/github.com/mojocn/sseread)
[](https://codecov.io/gh/mojocn/sseread)
[](https://github.com/mojocn/sseread)
[](https://github.com/mojocn)This is a straightforward library illustrating the method to read Server Sent Events (SSE) stream from the Response.Body in Golang.
## Usage
download the library using
`go get -u github.com/mojocn/sseread@latest`simple examples of how to use the library.
1. [read SSE by callback](https://pkg.go.dev/github.com/mojocn/sseread#example-Read)
2. [read SSE by channel](https://pkg.go.dev/github.com/mojocn/sseread#example-ReadCh)
3. [cloudflare AI text generation example](cloudflare_ai_test.go)## Testing
```bash
# git clone https://github.com/mojocn/sseread.git && cd sseread
go test -v
```