mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Use STDIN as writer for encoding func's JSON input data instead of buffering
This commit is contained in:
@@ -46,18 +46,12 @@ func (h *JSONProtocol) Dispatch(w io.Writer, req *http.Request) error {
|
|||||||
Headers: req.Header,
|
Headers: req.Header,
|
||||||
Body: body.String(),
|
Body: body.String(),
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(jin)
|
err := json.NewEncoder(h.in).Encode(&jin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this shouldn't happen
|
// this shouldn't happen
|
||||||
return respondWithError(
|
return respondWithError(
|
||||||
w, fmt.Errorf("error marshalling JSONInput: %s", err.Error()))
|
w, fmt.Errorf("error marshalling JSONInput: %s", err.Error()))
|
||||||
}
|
}
|
||||||
// TODO: write in chunks, how big should chunk be?
|
|
||||||
_, err = h.in.Write(b)
|
|
||||||
if err != nil {
|
|
||||||
return respondWithError(
|
|
||||||
w, fmt.Errorf("error writing JSON object to function's STDIN: %s", err.Error()))
|
|
||||||
}
|
|
||||||
|
|
||||||
if rw, ok := w.(http.ResponseWriter); ok {
|
if rw, ok := w.(http.ResponseWriter); ok {
|
||||||
// this has to be done for pulling out:
|
// this has to be done for pulling out:
|
||||||
|
|||||||
Reference in New Issue
Block a user