Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 1 month 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 (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-20T09:57:09.000Z (9 months ago)
- Last Synced: 2024-06-21T14:11:39.359Z (6 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
[![GoDoc](https://pkg.go.dev/badge/github.com/mojocn/sseread?status.svg)](https://pkg.go.dev/github.com/mojocn/sseread?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/mojocn/sseread?)](https://goreportcard.com/report/github.com/mojocn/sseread)
[![codecov](https://codecov.io/gh/mojocn/sseread/graph/badge.svg?token=3UC1L5K4LY)](https://codecov.io/gh/mojocn/sseread)
[![Go version](https://img.shields.io/github/go-mod/go-version/mojocn/sseread.svg)](https://github.com/mojocn/sseread)
[![Follow mojocn](https://img.shields.io/github/followers/mojocn?label=Follow&style=social)](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
```