Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDG-13557: GET method #3

Merged
merged 1 commit into from
Nov 24, 2023
Merged

EDG-13557: GET method #3

merged 1 commit into from
Nov 24, 2023

Conversation

francisf2
Copy link
Contributor

@francisf2 francisf2 commented Nov 23, 2023

Implement GET method for S3 and local directory services

@leshow
Copy link

leshow commented Nov 24, 2023

Looks fine to me, you may want to add some description in the PR though

@francisf2 francisf2 merged commit e2f215f into main Nov 24, 2023
1 check passed
plugin.next.ServeHTTP(rw, req)
}

func (plugin AwsPlugin) put(rw http.ResponseWriter, req *http.Request) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put is implemented for AwsPlugin but get is implemented for *AwsPlugin. Is that intentional?

@@ -39,13 +40,34 @@ type AwsPlugin struct {
}

func (plugin AwsPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
switch req.Method {
case "PUT":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use http.MethodPut and http.MethodGet

handleResponse(resp, err, rw)
}

func handleResponse(resp []byte, err error, rw http.ResponseWriter) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be confusing to use the name err as an argument and internal variable. I would rename the argument, maybe to requestErr

req, err := http.NewRequest("PUT", uri, bytes.NewReader(payload))
var payloadReader io.Reader = nil
if payload != nil {
payloadReader = bytes.NewReader(payload)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the payload may be big, it may be more efficient to use bufio.NewReader(..)

@@ -66,6 +72,14 @@ func (s3 *S3) Put(name string, payload []byte, contentType string, rw http.Respo
return response, nil
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use http.MethodPut and http.MethodGet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants