Addressing comments

This commit is contained in:
Denis Makogon
2017-08-03 23:28:35 +03:00
parent ab8134cbbb
commit 3af069ca5e
2 changed files with 5 additions and 7 deletions

View File

@@ -33,7 +33,7 @@ type callID struct {
Error apiErr `json:"error"`
}
func CallFN(u string, content io.Reader, output io.Writer, method string, env []string, ignoreCallID bool) error {
func CallFN(u string, content io.Reader, output io.Writer, method string, env []string, includeCallID bool) error {
if method == "" {
if content == nil {
method = "GET"
@@ -59,7 +59,7 @@ func CallFN(u string, content io.Reader, output io.Writer, method string, env []
}
// for sync calls
if call_id, found := resp.Header[FN_CALL_ID]; found {
if !ignoreCallID {
if includeCallID {
fmt.Fprint(os.Stderr, fmt.Sprintf("Call ID: %v\n", call_id[0]))
}
io.Copy(output, resp.Body)
@@ -73,9 +73,7 @@ func CallFN(u string, content io.Reader, output io.Writer, method string, env []
// - error in body
// that's why we need to check values of attributes
if c.CallID != "" {
if !ignoreCallID {
fmt.Fprint(os.Stderr, fmt.Sprintf("Call ID: %v\n", c.CallID))
}
fmt.Fprint(os.Stderr, fmt.Sprintf("Call ID: %v\n", c.CallID))
} else {
fmt.Fprint(output, fmt.Sprintf("Error: %v\n", c.Error.Message))
}

View File

@@ -62,7 +62,7 @@ var updateRouteFlags = append(routeFlags,
var callFnFlags = append(runflags(),
cli.BoolFlag{
Name: "ignore-call-id",
Name: "display-call-id",
Usage: "whether display call ID or not",
},
)
@@ -207,7 +207,7 @@ func (a *routesCmd) call(c *cli.Context) error {
u.Path = path.Join(u.Path, "r", appName, route)
content := stdin()
return client.CallFN(u.String(), content, os.Stdout, c.String("method"), c.StringSlice("e"), c.Bool("ignore-call-id"))
return client.CallFN(u.String(), content, os.Stdout, c.String("method"), c.StringSlice("e"), c.Bool("display-call-id"))
}
func routeWithFlags(c *cli.Context, rt *fnmodels.Route) {