Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
JSON lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jviide committed Dec 13, 2018
1 parent 8c9a8af commit 75e4f9f
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ func main() {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
writeAndFlush(w, "[")

stream := tracker.Get(id)
if stream == nil {
Expand Down Expand Up @@ -642,25 +641,16 @@ func main() {
goal = result.IP.Equal(ip)
}

if err := write(w, "\n "); err != nil {
log.Panic(err)
}
if err := writeJSON(w, obj); err != nil {
log.Panic(err)
}
if !goal {
if err := writeAndFlush(w, ","); err != nil {
log.Panic(err)
}
if err := write(w, "\n"); err != nil {
log.Panic(err)
}
if goal {
break
}
}

if err := writeAndFlush(w, "\n]\n"); err != nil {
log.Panic(err)
}
})

fmt.Printf("Serving on %v...\n", s.HostPort())
Expand Down

0 comments on commit 75e4f9f

Please sign in to comment.