🌲 REST κ°œλ…

  • Representational State Transfer의 μ•½μž

    • μžμ›μ„ μ΄λ¦„μœΌλ‘œ κ΅¬λΆ„ν•˜μ—¬ ν•΄λ‹Ή μžμ›μ˜ μƒνƒœλ₯Ό μ£Όκ³  λ°›λŠ” λͺ¨λ“  것을 의미

    • 즉, μžμ›(resource)의 ν‘œν˜„(representation)에 μ΄ν•œ μƒνƒœ 전달

      μžμ› : ν•΄λ‹Ή μ†Œν”„νŠΈμ›¨μ–΄κ°€ κ΄€λ¦¬ν•˜λŠ” λͺ¨λ“ κ²ƒ

      =>λ¬Έμ„œ, κ·Έλ¦Ό, 데엍, ν•΄λ‹Ή μ†Œν”„νŠΈμ›¨μ–΄

      μžμ›μ˜ ν‘œν˜„ : κ·Έμžμ›μ„ ν‘œν˜„ν•˜κΈ° μœ„ν•œ 이름

      =>정보가 μ§€μ›λ λ•Œ , 'data'λ₯Ό μžμ›μ˜ ν‘œν˜„μœΌλ‘œ μ •μ˜

      μƒνƒœ(정보) 전달

      데이터가 μš”μ²­λ˜μ–΄μ§€λŠ” μ‹œμ μ—μ„œ μžμ›μ˜ μƒνƒœλ₯Ό 전달
      JSON κ³Ό XMLλ₯Ό 톡햬써 데이터λ₯Ό μ£Όκ³  λ°›λŠ” 것이 일반적

🌡 REST의 ꡬ체적인 κ°œλ…

  • HTTP URLλ₯Ό 톡해 μžμ›μ„ λͺ…μ‹œν•˜κ³ , HTTP Method(GET, POST, PUT, DELETE)λ₯Ό 톡해 ν•΄λ‹Ή μžμ›μ— λŒ€ν•œ CRUD Operation을 μ μš©ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

    • 즉, REST μžμ› 기반의 ꡬ쑰인 (ROA, Resource Oriented Architecture) 섀계 쀑심에 Resource κ°€ 있고 HTTP Methodeλ₯Ό 톡해 Resourceλ₯Ό μ²˜λ¦¬ν•˜λ„λ‘ μ„€κ³„λœ μ•„ν‚€ν…μ³μž…λ‹ˆλ‹€.

    CRUD λž€?
    Create : 생성(POST)
    Read : 쑰회 (GET)
    Update : μˆ˜μ •(PUT)
    HEAD : header μ •λ³΄μ‘°νšŒ(HEAD)

🌾 REST ꡬ성 μš”μ†Œ

  1. μžμ› (Resource) : URI

    • λͺ¨λ“  μžμ›μ— κ³ μœ ν•œ IDκ°€ 쑴재, μžμ›μ€ Server 쑴재
    • μžμ›μ˜ IDλŠ” '/api/data/name_id' 와 같은 HTTP URI μž…λ‹ˆλ‹€.

    • ClientλŠ” URIλ₯Ό μ΄μš©ν•΄μ„œ μžμ›μ„ μ§€μ •ν•˜κ³  ν•΄λ‹Ή μžμ›μ˜ μƒνƒœμ— λŒ€ν•œ μ‘°μž‘μ„
      Server에 μš”μ²­ν•œλ‹€.

  1. ν–‰μœ„ (Verb) : HTTP Method
    • HTTP ν”„λ‘œν† μ½œμ˜ Method μ‚¬μš©
    • HTTP ν”„λ‘œν† μ½œμ€ GET, POST, PUT, DELETE λ§€μ„œλ“œ 제곡
  1. ν‘œν˜„ (representation of Resource)

    • Clientκ°€ μžμ›μ˜ μƒνƒœ(정보)에 λŒ€ν•œ μ‘°μž‘μ„ μš”μ²­ν•˜λ©΄ ServerλŠ” 이에 μ μ ˆν•œ 응닡

    • REST μ—μ„œ ν•˜λ‚˜μ˜ μžμ›μ€ JSON, XML, TEXT, RSSλ“± μ—¬λŸ¬ ν˜•νƒœ Representation 으둜 λ‚˜νƒ€λƒ…λ‹ˆλ‹€.

    • JSON or XMLλ₯Ό 톡해 데이터λ₯Ό μ£Όκ³ λ°›μŒ 일반적으둠

    🌱 REST의 νŠΉμ§•

    1. Server-Client(μ„œλ²„ - ν΄λΌμ΄μ–ΈνŠΈ ꡬ쑰)
      • μžμ›μ΄ μžˆλŠ” μͺ½μ΄ Server, μžμ›μ„ μš”μ²­ν•˜λŠ” μͺ½μ΄ Client

        REST Server : APIλ₯Ό μ œκ³΅ν•˜κ³  λΉ„μ¦ˆλ‹ˆμŠ€ 둜직 처리 및 μ €μž₯
        Client : μ‚¬μš©μž μΈμ¦μ΄λ‚˜ context(μ„Έμ…˜, λ‘œκ·ΈμΈμ •λ³΄) 등을 직접 κ΄€λ¦¬ν•˜κ³  μ±…μž„μ§„λ‹€..