rest - What is the proper RESTful way to handle a variable response for an endpoint that is based on the type of user that accesses it? -


i have resource endpoints respond differently user tries access endpoint.

scenario

let have resource endpoint /users, , following usertypes:

  • girluser
  • boyuser
  • admin

when girluser executes get on /users want allow other girlusers accessible. expect boyusers have similar result, , admins receive users.

my question

is more restful to:

  1. handle different granttypes or scopes through oauth, using 1 /users endpoint.
  2. have different endpoints, such as: users/girls, users/boys, , users/all.
  3. have different apis different types of users.
  4. i'm totally off-base possible answers , it's don't expect.

would change if have other endpoints want operational usertype?

(for example, ones process payments.)

thank you.

your endpoints should independent of sex of user. what's problem in having common user endpoint. (you doing right already!!)

though depends on kind of information want return, kind of resources in hand. returning json/xml? have girl , boy class work in backend. if girl user hits endpoint serialize objects , return data user - sounds okay me.

if uml design not differentiate between girls/boys should have same endpoint.

in order understand problem properly,
i) kind of data returning?
ii) how have designed uml?
iii) returning data db? expensive run girls/all boys query on everytime endpoint hit?

as scopes, in oauth 1 scope corresponds 1 endpoint. in google, g+ scope, google drive scope. don't see g+ girls, g+ boys scopes, now?

in java terms, closest match api design factory pattern (that's how explain myself, might not technically correct) - depending on type of user call specific method returns data. endpoint should generic , extensible - having separate api's indeed bad design leaves little expansion.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -