5
ltlian
2y

We had made an api which had endpoints for each different domain model, so /user, /company, the usual. Beyond being restful they all had basic filtering and pagination.

We also had an endpoint to return an entity from any set based on guid for when you needed to attach the related entity to notifications and logging and such.

We received a bug report on how you couldn't use filtering or pagination on this endpoint, and after weeks of asking what they need it for we just had to implement it.

You can imagine how non-trivial it is to "just" filter across different datasets, but we eventually got it working so now you can get a user via /user/123 or /entity?type=user&id=123. They only use it for one type and id at the time.

Comments
  • 2
    couldn't you just add a HTTP 301 to /{entityType}/{entityId}?
  • 1
    @tosensei We considered it, but their requirement was vague where they sort of wanted a generic search endpoint. You can query multiple types on it, it's just never used that way.
Add Comment