mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
improve fn run/call http method support (#505)
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
e47d9540c6
commit
f7a834d5ef
14
fn/routes.go
14
fn/routes.go
@@ -231,11 +231,19 @@ func (a *routesCmd) call(c *cli.Context) error {
|
||||
u.Path = path.Join(u.Path, "r", appName, route)
|
||||
content := stdin()
|
||||
|
||||
return callfn(u.String(), content, os.Stdout, c.StringSlice("e"))
|
||||
return callfn(u.String(), content, os.Stdout, c.String("method"), c.StringSlice("e"))
|
||||
}
|
||||
|
||||
func callfn(u string, content io.Reader, output io.Writer, env []string) error {
|
||||
req, err := http.NewRequest("POST", u, content)
|
||||
func callfn(u string, content io.Reader, output io.Writer, method string, env []string) error {
|
||||
if method == "" {
|
||||
if content == nil {
|
||||
method = "GET"
|
||||
} else {
|
||||
method = "POST"
|
||||
}
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, u, content)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error running route: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user