Skip to content

Commit 72d53a8

Browse files
committed
Update
1 parent 117354a commit 72d53a8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

restful_api.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ What's the point of all this? Come on, be professional!
1818
### Endpoint Design
1919

2020
- Keep in mind that REST is **resource oriented**, do not design endpoints casually.
21-
- Use **plural noun** as path for resource collection, like `/blogs`.
22-
- To represent a single resource out of a collection, use path like `/blogs/{id}`. The `{id}` is the unique identity(database id, unique name, etc) of a resource, and don't repeat the `{id}` in other request parameters.
21+
- Use **plural noun** as path for resource collection, like `/articles`.
22+
- To represent a single resource out of a collection, use path like `/articles/{id}`. The `{id}` is the unique identity(database id, unique name, etc) of a resource, and don't repeat the `{id}` in other request parameters.
2323
- Use HTTP verbs right, common CRUD cases:
2424

2525
Resource Path | POST | GET | PUT | PATCH | DELETE
2626
-------- | ---- | --- | --- | ----- | ------
27-
`/blogs` | create a new blog | list blogs | X | X | X
28-
`/blogs/{id}` | X | get a blog by id | update or create(if not exists yet) a blog by id | update a blog partially by id | delete a blog by id
27+
`/articles` | create a new article | list articles | X | X | X
28+
`/articles/{id}` | X | get a article by id | update or create(if not exists yet) a article by id | update a article partially by id | delete a article by id
2929

30-
- Resources can be nested, e.g. `/blogs/{blogId}/comments/{id}`, but not necessary, `/comments/{id}` is also ok, this is more a matter of style.
31-
- In some cases a property of a resource can be represented as a resource too, e.g. `PUT /blogs/{id}/title`.
32-
- Arbitrary meaningful information can be inserted into the resource path, e.g. `/it/blogs`(site category route), `/blogs/hot`(collection quick filter, only for `GET`), even `/it/blogs/hot`.
30+
- Resources can be nested, e.g. `/articles/{articleId}/comments/{id}`, but not necessary, `/comments/{id}` is also ok, this is more a matter of style.
31+
- In some cases a property of a resource can be represented as a resource too, e.g. `PUT /articles/{id}/title`.
32+
- Arbitrary meaningful information can be inserted into the resource path, e.g. `/it/articles`(site category route), `/articles/hot`(collection quick filter, only for `GET`), even `/it/articles/hot`.
3333
- A resource can be singleton without parent collection, e.g. `GET /appVersion`.
3434
- For unusual non-CRUD cases, always use POST + verb-ended path, e.g.:
35-
- `POST /blogs/{blogId}/translate`
36-
- `POST /blogs/batchUpdate`
37-
- `POST /blogs/batchDelete`
35+
- `POST /articles/{articleId}/translate`
36+
- `POST /articles/batchUpdate`
37+
- `POST /articles/batchDelete`
3838

3939
### Access Control
4040

0 commit comments

Comments
 (0)