From ce02f2a8fb6b9c5943545827707573817df04d0f Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Fri, 18 Dec 2020 06:50:02 +0000 Subject: [PATCH] error check to ensure path id doesn't conflict body id --- api/internal/handler/route/route.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/internal/handler/route/route.go b/api/internal/handler/route/route.go index 01ef7bffe2..e3ff63c650 100644 --- a/api/internal/handler/route/route.go +++ b/api/internal/handler/route/route.go @@ -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 }