Nikolay Fominyh Nikolay Fominyh - 1 year ago 94
reST (reStructuredText) Question

Restful way to design entites type.

We have scheme like:

class Entity:

class BigEntity(Entity):

class RedEntity(Entity):

Which way to represent them in REST is better:

  1. Create endpoint like
    and put entity type in request?

  2. Create endpoints like
    ? How to deal with list of all entities in this case?

Answer Source

You should choose a solution that makes it feel clean for you. There is no magic solution.

I wouldn't recommend using /entities/red/ and /entities/big/ because as a developer you expect /entities/{id} and not /entities/{type}.

You could use query parameters like /entities?type=red. It's clean too but maybe will be harder to maintain in your controllers.

Another solution might be /red-entities/, /big-entities/, /entities. It's clean, understandable and maintainable. It's the solution I prefer.

At the end of the day it really depends what feels cleaner and best understandable to you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download