I am building a Go DELETE REST endpoint. This request requires a set of query parameters which filters what objects to delete.
for eg.
As of now, if somebody sends a request like
my implementation deletes all users with age=24
and ignores the invalid userId123
.
I want to implement a way to check if the query parameter in the request is invalid. Having userId123
in the request in this case should return Bad Request
.
The only way that I can think of is, doing a string match for each parameter against the User
struct fields. I would like to know of a better way to do this.
All help appreciated. Using go version go version go1.13.4 darwin/amd64
and net/http
for http framework.