{"id":16813850,"url":"https://github.com/bmhatfield/sse","last_synced_at":"2025-07-02T09:06:04.239Z","repository":{"id":185982038,"uuid":"674428129","full_name":"bmhatfield/sse","owner":"bmhatfield","description":"Server sent events publisher in Go","archived":false,"fork":false,"pushed_at":"2024-01-13T15:41:48.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T11:50:55.663Z","etag":null,"topics":["go","golang","http","push","server-sent-events","sse"],"latest_commit_sha":null,"homepage":"","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/bmhatfield.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2023-08-03T23:46:19.000Z","updated_at":"2024-10-24T10:33:42.000Z","dependencies_parsed_at":"2024-01-13T17:00:31.073Z","dependency_job_id":"386952fa-66fe-4893-b2ff-bef93dd7d9ca","html_url":"https://github.com/bmhatfield/sse","commit_stats":null,"previous_names":["bmhatfield/sse"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bmhatfield/sse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmhatfield%2Fsse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmhatfield%2Fsse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmhatfield%2Fsse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmhatfield%2Fsse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmhatfield","download_url":"https://codeload.github.com/bmhatfield/sse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmhatfield%2Fsse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263108812,"owners_count":23415006,"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":["go","golang","http","push","server-sent-events","sse"],"created_at":"2024-10-13T10:28:01.639Z","updated_at":"2025-07-02T09:06:04.213Z","avatar_url":"https://github.com/bmhatfield.png","language":"Go","readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/bmhatfield/sse.svg)](https://pkg.go.dev/github.com/bmhatfield/sse)\n\n# github.com/bmhatfield/sse\n[Server sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) publisher in Go\n\n## Install\n\n`go get github.com/bmhatfield/sse`\n\n## Usage\n\nImport sse\n\n```go\nimport \"github.com/bmhatfield/sse\"\n```\n\nCreate the event server. The event server is an async topic publisher, with events pushed to active subscribers.\n\n```go\n// Create event server.\nevents := sse.NewEventServer()\n\n// Create initial topic\nevents.Create(\"topic-name\")\n```\n\nCreate an event, and then broadcast it to subscribers. Messages will be sent to active subscribers. Broadcasts to non-existent topics will fail. Broadcasts to topics without subscribers will be dropped.\n\n```go\n// Create an event\n// See also: JSONEvent, or implement your own Event!\nevent := sse.NewEvent(\"optional-kind\", []byte(\"hi!\"))\n\n// Broadcast!\nif err := events.Broadcast(\"topic-name\", event); err != nil {\n    log.Printf(\"failed to broadcast: %s\", err)\n}\n```\n\nThe event server is a simple HTTP handler. Use with your favorite router, or serve with the standard library.\n\n```go\n// Serve event stream\nhttp.Handle(\"/events\", events)\nif err := http.ListenAndServe(\":8080\", nil); err != nil {\n    log.Fatal(err)\n}\n```\n\nUse EventSource in `js` to listen for events. Clients can select their stream with the `stream` query param.\n\n```js\nconst stream = new EventSource(\"/events?stream=points\");\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmhatfield%2Fsse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmhatfield%2Fsse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmhatfield%2Fsse/lists"}