Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
```