Should the router handle 404's for URL's not in its route structure?
The argument for, is that any route under /my-api/ should be considered part of the API - even invalid routes such as /my-api/foobar. In this case, it's the responsibility of the API to return a JSON-API compliant error response.
The argument against is that only defined routes should be considered part of the API. An undefined route would not be naturally reachable by traversing the API with a properly behaving client. The only way to reach these URLs would be through a malformed client and/or through a user manually forming such a request.
Should the router handle 404's for URL's not in its route structure?
The argument for, is that any route under
/my-api/
should be considered part of the API - even invalid routes such as/my-api/foobar
. In this case, it's the responsibility of the API to return a JSON-API compliant error response.The argument against is that only defined routes should be considered part of the API. An undefined route would not be naturally reachable by traversing the API with a properly behaving client. The only way to reach these URLs would be through a malformed client and/or through a user manually forming such a request.