mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-21 23:44:41 +00:00
23 lines
441 B
Go
23 lines
441 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
)
|
|
|
|
func Events(eventChannel chan *logrus.Entry) func(w http.ResponseWriter, r *http.Request) {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
logrus.Info("New events")
|
|
formatter := &logrus.JSONFormatter{}
|
|
flusher, _ := w.(http.Flusher)
|
|
for {
|
|
e := <-eventChannel
|
|
b, _ := formatter.Format(e)
|
|
fmt.Fprintf(w, string(b))
|
|
flusher.Flush()
|
|
}
|
|
}
|
|
}
|