I have a question about the abilities of various back end frameworks to resolve potentially ambiguous incoming API calls....
So far we've tried to avoid ambiguity in our API urls, to make it as easy as possible for developers to produce them.
For example, we might have two APIs like this, one to view an existing product, and one to get a list of retired products:
- GET /products/{ID}
- GET /products/retired
Product ID is always an integer, so there's no ambiguity here ("retired" can never be used as an ID).
Spring MVC for example can deal with this, because it knows that ID must be a number (hence can't start with "r") by introspecting the arguments to the endpoints, e.g.:
@RequestMapping(value = "/products/{ID}")
public String viewProduct(@PathVariable("ID") Long productID) {
However we're concerned there may be other back end frameworks that can't easily deal with this kind of ambiguity.
So instead we've opted for the following, which is more verbose and feels slightly yuck:
- GET /products/byID/{ID}
- GET /products/retired
Does anyone have any knowledge or experience as to whether this is even necessary? We don't care too much about aged or arcane frameworks, but are there common garden frameworks that can't deal with these kind of semi-ambiguous situations? Or are we making our API signatures unnecessarily verbose for no strong reason?