Here's an example:
GET /posts
POST /posts
GET /posts/{post_id}
PUT /posts/{post_id}
This api is being used by SUPER_ADMIN as well as CONTENT_WRITERS. Its working great. If user is logged in as a SuperAdmin, he sees all the post, and if user is logged in as ContentWriter he sees only his post.
But, now the requirement is added, where SuperAdmin should be able to do CRUD opertations on behalf of any ContentWriter.
I added these APIs for that:
GET /user/{user_id}/posts
POST /user/{user_id}/posts
GET /user/{user_id}/posts/{post_id}
PUT /user/{user_id}/posts/{post_id}
Its working fine too. But the problem here is, now there are too many APIs/Controllers to maintain. Although, the controllers use the same service for that.
My question is, am I going to a right direction? Or is there any other best practices for this?
UPDATE 1
The idea here is somewhat similar to impersonation.
too many
are we speaking about thousands or just dozens of new methods? I do ask this because before re-factor something that it's proven to work (solving the problem) you have to find out whether the cost/benefits of a new solution outweighs (or not) the cost of the current one.