Use constant for GET/PUT/POST methods

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-10-23 16:41:53 +01:00
parent cbdbd2903c
commit 5e07b352bd
5 changed files with 6 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ func fetchMasterZip(templateUrl string) error {
timeout := 120 * time.Second
client := proxy.MakeHTTPClient(&timeout)
req, err := http.NewRequest("GET", templateUrl, nil)
req, err := http.NewRequest(http.MethodGet, templateUrl, nil)
if err != nil {
log.Println(err.Error())
return err

View File

@@ -60,10 +60,10 @@ func DeployFunction(fprocess string, gateway string, functionName string, image
timeout := 120 * time.Second
client := MakeHTTPClient(&timeout)
method := "POST"
method := http.MethodPost
// "application/json"
if update {
method = "PUT"
method = http.MethodPut
}
request, _ = http.NewRequest(method, gateway+"/system/functions", reader)

View File

@@ -22,7 +22,7 @@ func InvokeFunction(gateway string, name string, bytesIn *[]byte, contentType st
var timeout *time.Duration
client := MakeHTTPClient(timeout)
postRequest, _ := http.NewRequest("POST", gateway+"/function/"+name, reader)
postRequest, _ := http.NewRequest(http.MethodPost, gateway+"/function/"+name, reader)
res, err := client.Do(postRequest)
if err != nil {

View File

@@ -23,7 +23,7 @@ func ListFunctions(gateway string) ([]requests.Function, error) {
timeout := 120 * time.Second
client := MakeHTTPClient(&timeout)
getRequest, _ := http.NewRequest("GET", gateway+"/system/functions", nil)
getRequest, _ := http.NewRequest(http.MethodGet, gateway+"/system/functions", nil)
res, err := client.Do(getRequest)
if err != nil {
fmt.Println()

View File

@@ -90,7 +90,7 @@ func ParseYAMLData(fileData []byte, regex string, filter string) (*Services, err
// fetchYAML pulls in file from remote location such as GitHub raw file-view
func fetchYAML(address *url.URL) ([]byte, error) {
req, err := http.NewRequest("GET", address.String(), nil)
req, err := http.NewRequest(http.MethodGet, address.String(), nil)
if err != nil {
return nil, err
}