0419 - 0425
# 0419 - 0425
# 0420 - REST Resource Naming Guide
A resource can be a singleton or a collection.
νλμ 리μμ€λ μ±κΈν΄ λλ 컬λμ μ΄ λ μ μλ€.A resource may contain sub-collection resources also
리μμ€λ sub-collection 리μμ€λ₯Ό ν¬ν¨ν μ μλ€.
/customers/{Id}/accounts
# REST Resource λ€μ΄λ°
Use nouns to represent resources. (리μμ€λ₯Ό νννκΈ° μν΄μ λͺ
μ¬λ₯Ό μ¬μ©)
RESTful URIλ λ°λμ 리μμ€ κ·Έ μ체λ₯Ό μΈκΈν΄μΌ νλ©°, 리μμ€μ νλμ μΈκΈν΄μλ μλλ€.
μλ₯Ό λ€λ©΄, μλμ κ°μ 리μμ€λ€μ΄ μμ λ URIλ λ€μκ³Ό κ°μ΄ λμμΈ λ μ μλ€.
- Users of the system
- User Accounts
- Network Devices etc
http://api.example.com/device-management/managed-devices
http://api.example.com/device-management/managed-devices/{device-id}
http://api.example.com/user-management/users/
http://api.example.com/user-management/users/{id}
- document 리μμ€ λ¬Έμμ μ νμ λνλ λλ 'λ¨μ'λ₯Ό μ¬μ©.
http://api.example.com/device-management/managed-devices/{device-id}
http://api.example.com/user-management/users/{id}
http://api.example.com/user-management/users/admin
- collection 리μμ€ Collection λ¨μμ 리μμ€λ₯Ό νμν λλ '볡μ'λ₯Ό μ¬μ©
http://api.example.com/device-management/managed-devices
http://api.example.com/user-management/users
http://api.example.com/user-management/users/{id}/accounts
- store 리μμ€ μ μ₯μ κ΄ν μμ²μ ν΄λΌμ΄μΈνΈκ° κ΄λ¦¬νλ 리μμ€ μ μ₯μμ΄λ€. λ°λΌμ '볡μ'λ₯Ό μ¬μ©νλ€
http://api.example.com/song-management/users/{id}/playlists
- controller 리μμ€
컨νΈλ‘€λ¬ 리μμ€λ μ€ν κ°λ₯ν κΈ°λ₯κ³Ό ν¨κ» νλΌλ―Έν° νΉμ λ¦¬ν΄ κ°μΌλ‘ μ΄λ¦ μ§λλ€.
μ΄ λλ 'λμ¬'λ₯Ό μ¬μ©νλ€.
http://api.example.com/cart-management/users/{id}/cart/checkout
http://api.example.com/song-management/users/{id}/playlist/play
# URIμ μΌκ΄μ±
- κ³μΈ΅ ꡬ쑰λ₯Ό νννκΈ° μν΄μ '/'λ₯Ό μ¬μ©νλ€.
http://api.example.com/device-management
http://api.example.com/device-management/managed-devices
http://api.example.com/device-management/managed-devices/{id}
http://api.example.com/device-management/managed-devices/{id}/scripts
http://api.example.com/device-management/managed-devices/{id}/scripts/{id}
λμ '/'κ° λΆμ§ μλλ‘ νλ€.
μΈλλ° μ¬μ©μ νΌνλ©° '-'μ μ¬μ©νλ€.
νΈλ¦¬ν¨ + 컨벀μ μ μν€μ§ μν΄μ μλ¬Έμλ₯Ό μ¬μ©νλ€.
νμΌ νμ₯μλ₯Ό ν¬ν¨ νμ§ μλλ€.
URIλ₯Ό μ¬μ©ν΄μ CRUD κΈ°λ₯μ μνλμμμ νμν΄μλ μλλ€.
URIλ μμμ λγ ν μ΄λ ν νλμ λνλ΄λ©΄ μλκ³ , μμμ λ 립μ μΌλ‘ μλ³νλ λ°©μμΌλ‘ μ¬μ©λμ΄μΌ νλ€. μ΄λ€ κΈ°λ₯μ΄ μνλλμ§ νμνκΈ° μν΄μλ HTTP μμ² λ°©λ²μ μ¬μ©νλ€.
HTTP GET http://api.example.com/device-management/managed-devices //Get all devices
HTTP POST http://api.example.com/device-management/managed-devices //Create new Device
HTTP GET http://api.example.com/device-management/managed-devices/{id} //Get device for given Id
HTTP PUT http://api.example.com/device-management/managed-devices/{id} //Update device for given Id
HTTP DELETE http://api.example.com/device-management/managed-devices/{id} //Delete device for given Id
- 쿼리μ€νΈλ§μ μ΄μ©νλ κ²μ κ³ λ €ν΄λΌ
νΉμ 리μμ€μ μμ±μ κΈ°μ€μΌλ‘ μ λ ¬, νν°λ§μ μμ£Όνκ² λ μ μλ€. μ΄λ₯Ό μν΄μ μλ‘μ΄ APIλ₯Ό λ§λ€κΈ°λ³΄λ¨, μ λ ₯ 맀κ°λ³μλ₯Ό 쿼리μ€νΈλ§μ μ λ¬νλλ‘ νλ€.