Skip to content

Commit

Permalink
Do not add extra newline after streaming json response
Browse files Browse the repository at this point in the history
json.Encoder.Encode already adds a newline after each record:
https://pkg.go.dev/encoding/json#Encoder.Encode
  • Loading branch information
gammazero committed Jul 18, 2023
1 parent caa0bba commit 2236950
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 1 addition & 3 deletions rwriter/provider_response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func (pw *ProviderResponseWriter) WriteProviderResult(pr model.ProviderResult) e
if err != nil {
return err
}
if err = pw.WriteND(); err != nil {
return err
}
pw.Flush()
} else {
pw.result.ProviderResults = append(pw.result.ProviderResults, pr)
}
Expand Down
7 changes: 1 addition & 6 deletions rwriter/response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,10 @@ func (w *ResponseWriter) PathType() string {
return w.pathType
}

func (w *ResponseWriter) WriteND() error {
_, err := w.w.Write([]byte("\n"))
if err != nil {
return err
}
func (w *ResponseWriter) Flush() {
if w.f != nil {
w.f.Flush()
}
return nil
}

func (w *ResponseWriter) Cid() cid.Cid {
Expand Down

0 comments on commit 2236950

Please sign in to comment.