samedi 28 mars 2020

Special keyword as {id} in URI to identify special resource

I'm designing a REST API, and have a collections of items, just call it PROD;

PROD has its typicals endpoints that accept the typical operations (POST, GET and so on)

api/prods/AAAAA
api/prods/BBBBB
api/prods/CCCCC

Now, I'd like to identify a specific item called the current PROD;

The current PROD is one of the items choosed by a logic that resides completely in the backend, and should accept all the HTTP operations;

How should i create an endpoint to identify it?

is this a good choice?

api/prods/current

then, in the backend i transparently apply the operations to whatever item i consider current.

I'm trying to implements this solution but doesn't seems perfectly right.

Any ideas on how to handle this scenario right?

Aucun commentaire:

Enregistrer un commentaire