Skip to main content

RESTful API


REST(REpresentational state transfer)​

The REST architectural style emphasises the scalability of interactions between components, uniform interfaces, independent deployment of components, and the creation of a layered architecture to facilitate caching components to reduce user-perceived latency, enforce security, and encapsulate legacy systems.

URI(Uniform Resource Identifiers)​

<schema>://<authority>/<path>[?<query>][#<fragment>]

  • /λŠ” λ¦¬μ†ŒμŠ€ μ‚¬μ΄μ˜ 계측적 관계λ₯Ό λ‚˜νƒ€λ‚Ό λ•Œ μ‚¬μš©
  • URI의 λ§ˆμ§€λ§‰μ—λŠ” /λ₯Ό 뢙이지 μ•ŠμŒ
  • -λ₯Ό μ‚¬μš©ν•  수 있음
  • _λ₯Ό μ‚¬μš©ν•˜μ§€ μ•ŠμŒ
  • λŒ€μ†Œλ¬Έμžλ₯Ό ꡬ뢄, 일반적으둜 μ†Œλ¬Έμžλ₯Ό μ‚¬μš©

URI path​

  • Collection
    • μ—¬λŸ¬ λ¦¬μ†ŒμŠ€κ°€ λ“€μ–΄μžˆλŠ” ν•˜λ‚˜μ˜ 디렉토리λ₯Ό κ°€λ¦¬ν‚€λŠ” λ¦¬μ†ŒμŠ€, μ„œλ²„μ—μ„œ 관리
    • 볡수 λͺ…사λ₯Ό μ‚¬μš©
    • Ex) /products
  • Document
    • ν•˜λ‚˜μ˜ 객체λ₯Ό κ°€λ¦¬ν‚€λŠ” λ¦¬μ†ŒμŠ€
    • ν•˜μœ„ λ¦¬μ†ŒμŠ€λ₯Ό κ°€μ§ˆ 수 있음
    • λ‹¨μˆ˜ λͺ…사λ₯Ό μ‚¬μš©
    • Ex) /products/candy
  • Controller
    • νŠΉμ • λ™μž‘μ„ μ‹€ν–‰ν•˜λŠ” λ¦¬μ†ŒμŠ€
    • CRUD(Create, Read, Update, Delete) κΈ°λŠ₯에 맀핑 ν•  수 μ—†λŠ” κ²½μš°μ—λ§Œ κ΅¬ν˜„
    • ν•˜μœ„ λ¦¬μ†ŒμŠ€λ₯Ό κ°€μ§ˆ 수 μ—†μŒ
    • 동사λ₯Ό μ‚¬μš©
  • Store
    • Collectionκ³Ό μœ μ‚¬ν•˜μ§€λ§Œ ν΄λΌμ΄μ–ΈνŠΈκ°€ 관리

URI query​

HTTP Verb​

  • POST(Create): μƒˆλ‘œμš΄ λ¦¬μ†ŒμŠ€ 생성 λ˜λŠ” 컨트둀러 μ‹€ν–‰
  • GET(Read): λ¦¬μ†ŒμŠ€ 쑰회
  • PUT(Put): λ¦¬μ†ŒμŠ€ 전체 μ—…λ°μ΄νŠΈ
  • DELETE(Delete): λ¦¬μ†ŒμŠ€ μ‚­μ œ

HTTP status codes​