Skip to content

Commit

Permalink
error check to ensure path id doesn't conflict body id
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Dec 18, 2020
1 parent 2b1a19e commit ce02f2a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/internal/handler/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ type UpdateInput struct {

func (h *Handler) Update(c droplet.Context) (interface{}, error) {
input := c.Input().(*UpdateInput)

// check if id on path is == to id on body
if input.ID != "" && input.Route.ID != nil && input.ID != input.Route.ID {
return &data.SpecCodeResponse{StatusCode: http.StatusBadRequest},
fmt.Errorf("ID on path (%s) doesn't match ID on body (%s)", input.ID, input.Route.ID)
}

if input.ID != "" {
input.Route.ID = input.ID
}
Expand Down

0 comments on commit ce02f2a

Please sign in to comment.