Skip to content

Commit

Permalink
Merge pull request #15 from speakeasy-api/bflad/remove-get-head-metho…
Browse files Browse the repository at this point in the history
…d-req-body

fix: Remove GET/HEAD method request body handling
  • Loading branch information
bflad authored Sep 5, 2024
2 parents 84377b3 + 0f29124 commit ad5cf9c
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions internal/method/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,10 @@ func HandleDelete(w http.ResponseWriter, r *http.Request) {
}

func HandleGet(w http.ResponseWriter, r *http.Request) {
type RequestBody struct {
ID string `json:"id"`
}
type ResponseBody struct {
Status string `json:"status"`
}

var requestBody RequestBody

body, err := io.ReadAll(r.Body)

if err != nil {
utils.HandleError(w, err)
return
}

if err := json.Unmarshal(body, &requestBody); err != nil {
utils.HandleError(w, err)
return
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)

Expand All @@ -79,24 +62,6 @@ func HandleGet(w http.ResponseWriter, r *http.Request) {
}

func HandleHead(w http.ResponseWriter, r *http.Request) {
type RequestBody struct {
ID string `json:"id"`
}

var requestBody RequestBody

body, err := io.ReadAll(r.Body)

if err != nil {
utils.HandleError(w, err)
return
}

if err := json.Unmarshal(body, &requestBody); err != nil {
utils.HandleError(w, err)
return
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
}
Expand Down

0 comments on commit ad5cf9c

Please sign in to comment.