Skip to content

Commit

Permalink
Merge pull request #4 from bluecatengineering/EDG-13557
Browse files Browse the repository at this point in the history
EDG-13557: Review comments
  • Loading branch information
francisf2 authored Dec 6, 2023
2 parents e2f215f + 15d7af2 commit d4acfa5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ type AwsPlugin struct {

func (plugin AwsPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
switch req.Method {
case "PUT":
case http.MethodPut:
plugin.put(rw, req)
case "GET":
case http.MethodGet:
plugin.get(rw, req)
default:
http.Error(rw, fmt.Sprintf("Method %s not implemented", req.Method), http.StatusNotImplemented)
}
plugin.next.ServeHTTP(rw, req)
}

func (plugin AwsPlugin) put(rw http.ResponseWriter, req *http.Request) {
func (plugin *AwsPlugin) put(rw http.ResponseWriter, req *http.Request) {
payload, err := io.ReadAll(req.Body)
if err != nil {
rw.WriteHeader(http.StatusNotAcceptable)
Expand All @@ -67,15 +67,15 @@ func (plugin *AwsPlugin) get(rw http.ResponseWriter, req *http.Request) {
handleResponse(resp, err, rw)
}

func handleResponse(resp []byte, err error, rw http.ResponseWriter) {
if err != nil {
func handleResponse(resp []byte, reqErr error, rw http.ResponseWriter) {
if reqErr != nil {
rw.WriteHeader(http.StatusInternalServerError)
http.Error(rw, fmt.Sprintf("Put error: %s", err.Error()), http.StatusInternalServerError)
log.Error(err.Error())
http.Error(rw, fmt.Sprintf("Put error: %s", reqErr.Error()), http.StatusInternalServerError)
log.Error(reqErr.Error())
return
}
rw.WriteHeader(http.StatusOK)
_, err = rw.Write(resp)
_, err := rw.Write(resp)
if err != nil {
http.Error(rw, string(resp)+err.Error(), http.StatusBadGateway)
}
Expand Down
2 changes: 1 addition & 1 deletion ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func getCredentials(creds *Credentials) {
}

func refreshCredentials(creds *Credentials, client *http.Client, credsUri string) error {
req, err := http.NewRequest("GET", credsUri, nil)
req, err := http.NewRequest(http.MethodGet, credsUri, nil)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func (s3 *S3) request(httpMethod string, name string, payload []byte, contentTyp
}

func (s3 *S3) Put(name string, payload []byte, contentType string, rw http.ResponseWriter) ([]byte, error) {
return s3.request("PUT", name, payload, contentType, rw)
return s3.request(http.MethodPut, name, payload, contentType, rw)
}

func (s3 *S3) Get(name string, rw http.ResponseWriter) ([]byte, error) {
return s3.request("GET", name, nil, "", rw)
return s3.request(http.MethodGet, name, nil, "", rw)
}

func copyHeader(dst, src http.Header) {
Expand Down
2 changes: 1 addition & 1 deletion signer/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestSignerV4(t *testing.T) {
Service: "s3",
}

r1, _ := http.NewRequest("PUT", "https://examplebucket.s3.amazonaws.com/text/test/file.text", bytes.NewReader([]byte("")))
r1, _ := http.NewRequest(http.MethodPut, "https://examplebucket.s3.amazonaws.com/text/test/file.text", bytes.NewReader([]byte("")))

testCases := []struct {
name string
Expand Down

0 comments on commit d4acfa5

Please sign in to comment.