mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
CloudEvents I/O format support. (#948)
* CloudEvents I/O format support. * Updated format doc. * Remove log lines * This adds support for CloudEvent ingestion at the http router layer. * Updated per comments. * Responds with full CloudEvent message. * Fixed up per comments * Fix tests * Checks for cloudevent content-type * doesn't error on missing content-type.
This commit is contained in:
@@ -115,7 +115,7 @@ func (h *JSONProtocol) Dispatch(ctx context.Context, ci CallInfo, w io.Writer) e
|
||||
if !ok {
|
||||
// logs can just copy the full thing in there, headers and all.
|
||||
err := json.NewEncoder(w).Encode(jout)
|
||||
return h.isExcessData(err, decoder)
|
||||
return isExcessData(err, decoder)
|
||||
}
|
||||
|
||||
// this has to be done for pulling out:
|
||||
@@ -144,10 +144,10 @@ func (h *JSONProtocol) Dispatch(ctx context.Context, ci CallInfo, w io.Writer) e
|
||||
}
|
||||
|
||||
_, err = io.WriteString(rw, jout.Body)
|
||||
return h.isExcessData(err, decoder)
|
||||
return isExcessData(err, decoder)
|
||||
}
|
||||
|
||||
func (h *JSONProtocol) isExcessData(err error, decoder *json.Decoder) error {
|
||||
func isExcessData(err error, decoder *json.Decoder) error {
|
||||
if err == nil {
|
||||
// Now check for excess output, if this is the case, we can be certain that the next request will fail.
|
||||
reader, ok := decoder.Buffered().(*bytes.Reader)
|
||||
|
||||
Reference in New Issue
Block a user