Update json (#463)

* wip

* wip

* Added more fields to JSON and added blank line between objects.

* Update tests.

* wip

* Updated to represent recent discussions.

* Fixed up the json test

* More docs

* Changed from blank line to bracket, newline, open bracket.

* Blank line added back, easier for delimiting.
This commit is contained in:
Travis Reeder
2017-11-16 09:59:13 -08:00
committed by GitHub
parent 279e5248ba
commit 96cfc9f5c1
8 changed files with 266 additions and 81 deletions

View File

@@ -2,6 +2,7 @@ package protocol
import (
"bufio"
"context"
"fmt"
"io"
"net/http"
@@ -25,8 +26,8 @@ func (p *HTTPProtocol) IsStreamable() bool { return true }
// over the timeout.
// TODO maybe we should take io.Writer, io.Reader but then we have to
// dump the request to a buffer again :(
func (h *HTTPProtocol) Dispatch(w io.Writer, req *http.Request) error {
err := DumpRequestTo(h.in, req) // TODO timeout
func (h *HTTPProtocol) Dispatch(ctx context.Context, ci CallInfo, w io.Writer) error {
err := DumpRequestTo(h.in, ci.Request()) // TODO timeout
if err != nil {
return err
}
@@ -36,7 +37,7 @@ func (h *HTTPProtocol) Dispatch(w io.Writer, req *http.Request) error {
// and status code first since calling res.Write will just write the http
// response as the body (headers and all)
res, err := http.ReadResponse(bufio.NewReader(h.out), req) // TODO timeout
res, err := http.ReadResponse(bufio.NewReader(h.out), ci.Request()) // TODO timeout
if err != nil {
return err
}
@@ -54,7 +55,7 @@ func (h *HTTPProtocol) Dispatch(w io.Writer, req *http.Request) error {
} else {
// logs can just copy the full thing in there, headers and all.
res, err := http.ReadResponse(bufio.NewReader(h.out), req) // TODO timeout
res, err := http.ReadResponse(bufio.NewReader(h.out), ci.Request()) // TODO timeout
if err != nil {
return err
}