Nesting RESTful Paths

I am creating a web service and I have some questions regarding path names. How do you define resource actions in a RESTful web service?

For example: Quiz resource. You have normal CRUD actions, and you also want to do something with the quiz. For example, creating a new quiz. This is an action. Are you using a path, for example, /quiz/top5or /quiz?type=top5or what?

I do not understand how you write the paths that perform actions on a resource when creating a RESTful service.

+5
source share
6 answers

I would recommend this book from apigee : Web Design API: Creating Interfaces that Developers Love .

Following their advice:

  • RESTful: .
  • URL.
+------------+-------------------+--------------+----------------------------------------+------------------+
| Resource   | POST create       | GET read     | PUT update                             | DELETE delete    |
| /quizzes   | Create a new quiz | List quizs   | Bulk update quizs                      | Delete all quizs |
| /quizes/12 | Error             | Show Quiz 12 | If exists update Quiz 12, if not Error | Delete Quiz 12   |
+------------+-------------------+--------------+-----------------------------------------+------------------+

, , , , , " ", :

quizzes/top?limit=5

quizs/top (5 10 ), .

+1

- RESTful .

/ URL- RESTful?, ?

: . quiz/show/{id}, quiz/top/{number} ..

: , Rails Convention. http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions

0

fooobar.com/questions/27444/... .

, , API GET POST. , GET, , (, ), POST ( DELETE, ), , , - .

0

, URL- REST, .

URL-, /{type}/{operation}/{param1}/{param2}...

maitainable ( ?=, )

/quiz/top/5 top 100, /quiz/top/100

0

URL- . HTTP- ( ), .

:

/quiz/top5
  • HTTP GET. top5, ? ? ( GET - ).
  • HTTP POST. .
0

All Articles