Closed dragonsinth closed 3 years ago
Obviously, I'm going to have to rebase this and make it work post encoder refactor. The big open question is, do we:
1) hard code the codecs as in this PR or
2) encoding.GetCodec("json")
, but only for application/json?
FWIW, if we wanted to support some variant of json streaming, we could probably use https://en.wikipedia.org/wiki/JSON_streaming#Record_separator-delimited_JSON
e.g.
const RecordSep = 0x1E
const Newline = 0x0a
- hard code the codecs as in this PR or
- encoding.GetCodec("json"), but only for application/json?
I'm personally for option one, since there's no on-rails way to wire up a JSON codec -- every consumer would have to implement it and register it.
Perhaps some middle ground: query for a codec, but if it doesn't exist use a default. And I think the default should probably be a zero-value jsonpb marshaler.
RE: streaming JSON, with Go it's easiest to do concatenated JSON (since json.Decoder
knows how to parse one value at a time). But it would be more important to know what's easiest to do from the browser/TS side of things. I'd totally have streams fail fast and leave it as a TODO for now though...
Leaving this branch in place to pin the SHA, but closing the PR. Superceded by #58
Re-opening the original formulation of #40