REST URLs that don't list items -


is okay use url /users/:user_id in rest api if there should no possibility list users /users?

if "yes" should /users return 404 or empty list?

rest has defined constraints. can read them in fielding dissertation.

there no constraint how design uri structure, because clients have decoupled it. not rest concern.

to short can have nice uris , use custom conventions build them. have aware few things only:

  • a single uri can identify single resource (but single resource can have multiple different uris) - uniform interface constraint / identifying resources
  • the uri path hierarchical query non-hierarchical - uri standard (it can subjective hierarchical , not)
  • the query part of uri (but can have own routing convention, example path can identify resource , query can describe representation details)
  • the uris mapped resources , not operations (as soap), if human readable uri contains verb, uri mapping flawed

if "yes" should /users return 404 or empty list?

if don't want show user list somebody, don't put link in responses pointing user list. if call uri manually, can send 404 not found or 403 forbidden, maybe 401 unauthorized. btw. if show user list containing current user only.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -