{"id":28747879,"url":"https://github.com/jetify-com/sse","last_synced_at":"2025-06-16T17:12:10.815Z","repository":{"id":295236129,"uuid":"987805199","full_name":"jetify-com/sse","owner":"jetify-com","description":"Server-Sent Events for Go. A tiny, dependency-free, spec-compliant library compatible with the HTTP stdlib.","archived":false,"fork":false,"pushed_at":"2025-05-27T15:45:51.000Z","size":38,"stargazers_count":89,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-08T16:47:29.750Z","etag":null,"topics":["event-driven","go","golang","real-time","realtime","server-sent-events","sse","sse-client","streaming"],"latest_commit_sha":null,"homepage":"https://www.jetify.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jetify-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-21T15:59:01.000Z","updated_at":"2025-06-04T02:20:01.000Z","dependencies_parsed_at":"2025-05-24T11:48:13.564Z","dependency_job_id":null,"html_url":"https://github.com/jetify-com/sse","commit_stats":null,"previous_names":["jetify-com/sse"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jetify-com/sse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Fsse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Fsse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Fsse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Fsse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jetify-com","download_url":"https://codeload.github.com/jetify-com/sse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Fsse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260203959,"owners_count":22974100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-driven","go","golang","real-time","realtime","server-sent-events","sse","sse-client","streaming"],"created_at":"2025-06-16T17:12:09.538Z","updated_at":"2025-06-16T17:12:10.808Z","avatar_url":"https://github.com/jetify-com.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sse – Server‑Sent Events for Go\n\n### A tiny, dependency‑free library that makes it easy to use SSE streaming with any HTTP framework.\n\n[![Version](https://img.shields.io/github/v/release/jetify-com/sse?color=green\u0026label=version\u0026sort=semver)](https://github.com/jetify-com/sse/releases)\n[![Go Reference](https://pkg.go.dev/badge/go.jetify.com/sse)](https://pkg.go.dev/go.jetify.com/sse)\n[![License](https://img.shields.io/github/license/jetify-com/sse)]()\n[![Join Discord](https://img.shields.io/discord/903306922852245526?color=7389D8\u0026label=discord\u0026logo=discord\u0026logoColor=ffffff\u0026cacheSeconds=1800)](https://discord.gg/jetify)\n\n*Primary Author(s)*: [Daniel Loreto](https://github.com/loreto)\n\n---\n\n## Introduction\nJetify's `sse` package is a tiny, dependency‑free library that makes it easy to use SSE streaming with any HTTP framework.\n\nIt is maintained and developed by [Jetify](https://www.jetify.com) and used by our AI agents to handle\nSSE in production settings.\n\n## ✨ Features\n\n* **Spec‑compliant**: Follows the [official WHATWG spec](https://html.spec.whatwg.org/multipage/server-sent-events.html) for server-side events.\n* **Zero dependencies**: Depends only on the go standard library.\n* **Well-tested** Comprehensive test suite with \u003e90% coverage, including end-to-end tests.\n* **Framework Agnostic**: Designed to be used with any Go HTTP framework.\n* **Flexible Encoding**: Supports both JSON and raw data encoding.\n\n## Quick Start\n\n### Server (Sending Events)\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n    \"time\"\n    \n    \"go.jetify.com/sse\"\n)\n\nfunc eventsHandler(w http.ResponseWriter, r *http.Request) {\n    // Upgrade HTTP connection to SSE\n    conn, err := sse.Upgrade(r.Context(), w)\n    if err != nil {\n        http.Error(w, err.Error(), http.StatusInternalServerError)\n        return\n    }\n    defer conn.Close()\n    \n    // Send events until client disconnects\n    count := 0\n    ticker := time.NewTicker(time.Second)\n    defer ticker.Stop()\n    \n    for {\n        select {\n        case \u003c-ticker.C:\n            // Send a simple event with JSON data\n            event := \u0026sse.Event{\n                ID:    fmt.Sprintf(\"%d\", count),\n                Data:  map[string]any{\"count\": count, \"time\": time.Now().Format(time.RFC3339)},\n            }\n            \n            if err := conn.SendEvent(r.Context(), event); err != nil {\n                log.Printf(\"Error: %v\", err)\n                return\n            }\n            count++\n            \n        case \u003c-r.Context().Done():\n            return // Client disconnected\n        }\n    }\n}\n\nfunc main() {\n    http.HandleFunc(\"/events\", eventsHandler)\n    log.Println(\"SSE server starting on :8080\")\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n### Client (Receiving Events)\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n    \n    \"go.jetify.com/sse\"\n)\n\nfunc main() {\n    // Make request to SSE endpoint\n    resp, err := http.Get(\"http://localhost:8080/events\")\n    if err != nil {\n        log.Fatalf(\"Failed to connect: %v\", err)\n    }\n    defer resp.Body.Close()\n    \n    // Create decoder for the SSE stream\n    decoder := sse.NewDecoder(resp.Body)\n    \n    // Process events as they arrive\n    for {\n        var event sse.Event\n        err := decoder.Decode(\u0026event)\n        if err != nil {\n            log.Printf(\"Stream ended: %v\", err)\n            break\n        }\n        \n        fmt.Printf(\"Event ID: %s, Data: %v\\n\", event.ID, event.Data)\n    }\n}\n```\n\n## Documentation\n\nThe following dcumentation is available:\n\n* **[API Reference](https://pkg.go.dev/go.jetify.com/sse)** - Complete Go package documentation\n* **[Examples](examples/)** - Real-world usage patterns\n\n## Community \u0026 Support\n\nJoin our community and get help:\n\n* **Discord** – [https://discord.gg/jetify](https://discord.gg/jetify) (best for quick questions \u0026 showcase)\n* **GitHub Discussions** – [Discussions](https://github.com/jetify-com/sse/discussions) (best for ideas \u0026 design questions)\n* **Issues** – [Bug reports \u0026 feature requests](https://github.com/jetify-com/sse/issues)\n\n## Contributing\n\nWe 💖 contributions! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## License\n\nLicensed under the **Apache 2.0 License** – see [LICENSE](LICENSE) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetify-com%2Fsse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjetify-com%2Fsse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetify-com%2Fsse/lists"}