-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
Looks fine to me, you may want to add some description in the PR though |
plugin.next.ServeHTTP(rw, req) | ||
} | ||
|
||
func (plugin AwsPlugin) put(rw http.ResponseWriter, req *http.Request) { |
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Implement GET method for S3 and local directory services