Skip to content

Commit

Permalink
Merge pull request #10 from jasongoodwin/main
Browse files Browse the repository at this point in the history
fix(aws): missing verb at interface.
  • Loading branch information
francisf2 authored Feb 26, 2024
2 parents feef16f + b986639 commit 7b57793
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func (plugin AwsPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodPut:
plugin.put(rw, req)
case http.MethodPost:
plugin.post(rw, req)
case http.MethodGet:
plugin.get(rw, req)
default:
Expand All @@ -63,6 +65,17 @@ func (plugin *AwsPlugin) put(rw http.ResponseWriter, req *http.Request) {
handleResponse(resp, err, rw)
}

func (plugin *AwsPlugin) post(rw http.ResponseWriter, req *http.Request) {
payload, err := io.ReadAll(req.Body)
if err != nil {
rw.WriteHeader(http.StatusNotAcceptable)
log.Error(fmt.Sprintf("Reading body failed: %s", err.Error()))
return
}
resp, err := plugin.service.Post(req.URL.Path[1:], payload, req.Header.Get("Content-Type"), rw)
handleResponse(resp, err, rw)
}

func (plugin *AwsPlugin) get(rw http.ResponseWriter, req *http.Request) {
resp, err := plugin.service.Get(req.URL.Path[1:], rw)
handleResponse(resp, err, rw)
Expand Down

0 comments on commit 7b57793

Please sign in to comment.