Skip to content

Commit

Permalink
Handle StatusAccepted in invoke proxy, print message and fix example
Browse files Browse the repository at this point in the history
This commit adds handling for the StatusAccepted response in the invoke
proxy, on receipt of a StatusAccepted reponse a message indicating
succesful submission is printed to stderr.

It also fixes the header in the callback invoke example.

Signed-off-by: John McCabe <[email protected]>
  • Loading branch information
johnmccabe authored and alexellis committed Mar 2, 2018
1 parent 5db060e commit 017665c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commands/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var invokeCmd = &cobra.Command{
faas-cli invoke echo --gateway https://domain:port --content-type application/json
faas-cli invoke env --query repo=faas-cli --query org=openfaas
faas-cli invoke env --header X-Ping-Url=http://request.bin/etc
faas-cli invoke resize-img --async -H "X-Callback-Url: http://gateway:8080/function/send2slack" < image.png
faas-cli invoke resize-img --async -H "X-Callback-Url=http://gateway:8080/function/send2slack" < image.png
faas-cli invoke env -H X-Ping-Url=http://request.bin/etc`,
RunE: runInvoke,
}
Expand Down
3 changes: 3 additions & 0 deletions proxy/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package proxy

import (
"bytes"
"os"

"fmt"
"io/ioutil"
Expand Down Expand Up @@ -69,6 +70,8 @@ func InvokeFunction(gateway string, name string, bytesIn *[]byte, contentType st
}

switch res.StatusCode {
case http.StatusAccepted:
fmt.Fprintf(os.Stderr, "Function submitted asynchronously.\n")
case http.StatusOK:
var readErr error
resBytes, readErr = ioutil.ReadAll(res.Body)
Expand Down

0 comments on commit 017665c

Please sign in to comment.