๐ฟ Spring/โ
RESTful Web Service
6. RESTful API ์ค๊ณ ๊ฐ์ด๋
nitronium102
2023. 6. 20. 03:07
Richardson Maturity Model
A way to grade your API according to the constraints of REST
Level 0
expose soap web services in rest style
Level 1
expose resources with proper url
note : improper use of http methods → ๋ชจ๋ ์์ฒญ์ GET, POST๋ก ๋ฐ๊ฑฐ๋ ์๋ฌ/200์ผ๋ก๋ง ๋ฐํํ๋ ํํ
Level 2
level1 + HTTP methods(GET, POST, PUT, DELETE ๊ตฌ๋ถ)
Level 3
level2 + HATEOAS
DATA + NEXT POSSIBLE ACTIONS ⇒ ์ต์ํ์ end point๋ง์ ๊ฐ์ง๊ณ ๋ค์ url์ ์ ์ ์๊ฒ ํจ
์ค๊ณ ์ ๊ณ ๋ ค ์ฌํญ
- consumer first : ๊ฐ๋ฐ์ ์ค์ฌ์ ์ค๊ณ ๋ณด๋ค๋ ์๋น์ ์ ์ฅ์์ ๊ฐ๋จ๋ช ๋ฃํ๊ณ ์ง๊ด์ ์ธ API ์ค๊ณ
- make best use of HTTP : HTTP ์ฅ์ ์ด๋ฆฌ๊ธฐ
- Request methods
- GET
- POST
- PUT
- DELETE
- Response Status
- 200
- 404
- 400
- 201
- 401
- No secure info in URI
- use plurals
prefer users to user
- use nouns for resources
- for exceptions
define a consistent approach
url์ ๋จ์ํ๊ฒ, parameter/header/HTTP ์ํ์ฝ๋๋ฅผ ๋ค์ํ๊ฒ
PUT /gists/{id}/star
DELETE /gists/{id}/star