I am trying to build a REST application in Spring where I have a requirement to delete resources on the basis of certain path variables.
For example, I want to delete resource(s) by id
@DeleteMapping("resources/{id}")
or by name
@DeleteMapping("resources/{name}")
But when I do the above, I get the error
java.lang.IllegalStateException: Ambiguous handler methods
As I understand, Servlets can't tell whether 123
in path /resources/123
represents an ID or a name and hence the ambiguity.
How shall then I design my REST endpoint where a DELETE happens based on some parameter or maybe a combination of parameters?