Skip to content

tdburke/eventsource

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1

go-eventsource

go-eventsource provides server-sent events for net/http server.

Usage

package main

import (
    eventsource "github.com/antage/go-eventsource/http"
    "log"
    "net/http"
    "strconv"
    "time"
)

func main() {
    es := eventsource.New()
    defer es.Close()
    http.Handle("/events", es)
    go func() {
        id := 1
        for {
            es.SendMessage("tick", "tick-event", strconv.Itoa(id))
            id++
            time.Sleep(2 * time.Second)
        }
    }()
    log.Fatal(http.ListenAndServe(":8080", nil))
}

Touched bottom

About

Server-sent events for Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%