[Android] OkHttp์™€ Retrofit

๐Ÿ’ก์•ˆ๋“œ๋กœ์ด๋“œ ๋„คํŠธ์›Œํฌ ํ†ต์‹ ์„ ์œ„ํ•œ HTTP ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋Œ€ํ•˜์—ฌ ํ•™์Šตํ•œ ๋‚ด์šฉ์„ ๊ธฐ๋กํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

๊ฐœ์š”

  • OkHttp์™€ Retrofit์€ ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ๋„คํŠธ์›Œํฌ ํ†ต์‹ ์„ ์‰ฝ๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” HTTP ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.
  • ๋‘˜ ๋‹ค ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ๋งค์šฐ ์œ ์šฉํ•˜์ง€๋งŒ, Retrofit์€ ์ƒ์œ„ ๋ ˆ๋ฒจ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ OkHttp๋ฅผ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ, ๋” ๊ฐ„๋‹จํ•œ API๋ฅผ ์ œ๊ณตํ•˜์—ฌ ๋„คํŠธ์›Œํฌ ์ž‘์—…์„ ์‰ฝ๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค๋‹ˆ๋‹ค.
  • OkHttp์™€ Retrofit์„ ํ•™์Šตํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ๊ฐœ๋…์„ ํ•จ๊ป˜ ์ •๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.

HTTP

  • HypeText Transfer Protocol์˜ ์•ฝ์ž๋กœ, ์ธํ„ฐ๋„ท ์ƒ์—์„œ HTML ๋ฌธ์„œ์™€ ๊ฐ™์€ ๋ฐ์ดํ„ฐ๋ฅผ ๋งํฌ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฃผ๊ณ ๋ฐ›๊ธฐ ์œ„ํ•œ ํ”„๋กœํ† ์ฝœ(ํ†ต์‹  ๊ทœ์•ฝ)์ž…๋‹ˆ๋‹ค.
  • ์„œ๋ฒ„-ํ‚…๋ผ์ด์–ธํŠธ ๋ชจ๋ธ๋กœ ๊ตฌ๋ถ„ํ•˜๋ฉฐ ์ „์†ก ์ œ์–ด ํ”„๋กœํ† ์ฝœ(TCP)๊ณผ ์ธํ„ฐ๋„ท ํ”„๋กœํ† ์ฝœ(IP) ์œ„์—์„œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

HTTPS

  • HTTP + Secure Socket(๋ณด์•ˆ ํ†ต์‹ )์˜ ์•ฝ์ž๋กœ ๋ชจ๋“  ํ†ต์‹  ๋‚ด์šฉ์„ ์•”ํ˜ธํ™”ํ•˜๋ฉฐ, ๊ณต๊ฐœํ‚ค ์•”ํ˜ธํ™” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

REST

  • REST(Representational State Transfer)๋Š” ์›น ์„œ๋น„์Šค๋ฅผ ์„ค๊ณ„ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋Š” ์•„ํ‚คํ…์ฒ˜ ์Šคํƒ€์ผ์ž…๋‹ˆ๋‹ค.
  • REST๋Š” ์ธํ„ฐ๋„ท์—์„œ ์›น ์„œ๋น„์Šค ๊ฐ„์˜ ํ†ต์‹ ์„ ์šฉ์ดํ•˜๊ฒŒ ํ•˜๋Š” ๋ช‡ ๊ฐ€์ง€ ๊ธฐ๋ณธ ์›์น™์„ ์ œ์‹œํ•˜๋Š”๋ฐ, ์ด๋ฅผ ๋”ฐ๋ฅด๋Š” API๋ฅผ REST API ๋˜๋Š” RESTful API๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

API

  • ์ •๋ณด ์ œ๊ณต์ž๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์— ๋Œ€ํ•ด ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์—์„œ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“  ์ธํ„ฐํŽ˜์ด์Šค์ž…๋‹ˆ๋‹ค.

REST API

  • Representational State Transfer API๋กœ URI๋กœ ์ž์›(์ด๋ฏธ์ง€, ๋™์˜์ƒ, DB ๋ฐ์ดํ„ฐ)์„ ํ‘œํ˜„ํ•˜๋Š” ๋ฐ์— ์ง‘์ค‘ํ•˜๊ณ , ์ž์›์˜ ์ƒํƒœ(ํ–‰์œ„)์— ๋Œ€ํ•œ ์ •์˜๋ฅผ HTTP Method๋กœ ํ•˜๋Š” ์•„ํ‚คํ…์ฒ˜์ž…๋‹ˆ๋‹ค.
    • HTTP Method : CRUD ์ž‘์—… ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋ฉ”์„œ๋“œ
  • ํด๋ผ์ด์–ธํŠธ๋Š” ์ž์›์˜ ์ƒํƒœ์— ๋Œ€ํ•œ ์กฐ์ž‘์„ ์š”์ฒญํ•˜๊ณ  ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ๋ฐ›์€ ์‘๋‹ต์ธ JSON, XML๋กœ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.
  • ์ด๋Š” REST ์•„ํ‚คํ…์ฒ˜์˜ ์ œ์•ฝ์กฐ๊ฑด์„ ์ค€์ˆ˜ํ•˜๋Š” API๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

OkHttp

  • OkHttp๋Š” HTTP ์š”์ฒญ ๋ฐ ์‘๋‹ต์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ €์ˆ˜์ค€์˜ HTTP ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.
  • ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ HTTP ํ†ต์‹ ์„ ํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋ฉฐ, ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ๊ฐ„์†Œํ™”ํ•˜๊ณ  ํšจ์œจ์ ์ธ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ์žฌ์‚ฌ์šฉ ๋ฐ ์บ์‹ฑ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

https://square.github.io/okhttp/

 

Overview - OkHttp

OkHttp HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP efficiently makes your stuff load faster and saves bandwidth. OkHttp is an HTTP client that’s efficient by default: HTTP/2 support allows all requests to

square.github.io

์ฃผ์š” ๊ธฐ๋Šฅ

  • HTTP/2 ๋ฐ SPDY ์ง€์›
    • ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ์„ฑ๋Šฅ์„ ๊ฐœ์„ ํ•˜๊ณ , ๋” ์ ์€ ๋Œ€์—ญํญ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • ์ปค๋„ฅ์…˜ ํ’€
    • ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์„ ์žฌ์‚ฌ์šฉํ•˜์—ฌ ์„ฑ๋Šฅ์„ ์ตœ์ ํ™”ํ•ฉ๋‹ˆ๋‹ค.
  • ์บ์‹ฑ
    • ์„œ๋ฒ„๊ฐ€ ์‘๋‹ตํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋กœ์ปฌ์— ์žฌ์‚ฌ์šฉํ•˜๋ฉฐ, ๋„คํŠธ์›Œํฌ ์š”์ฒญ ์ˆ˜๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋น„๋™๊ธฐ ๋ฐ ๋™๊ธฐ ์š”์ฒญ
    • ๋น„๋™๊ธฐ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ์‰ฝ๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๋™๊ธฐ ์š”์ฒญ๋„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  • ์ธํ„ฐ์…‰ํ„ฐ
    • ๋„คํŠธ์›Œํฌ ์š”์ฒญ ๋ฐ ์‘๋‹ต์„ ๊ฐ€๋กœ์ฑ„์„œ ๋กœ๊น…, ํ—ค๋” ์ถ”๊ฐ€, ์ธ์ฆ๊ณผ ๊ฐ™์€ ์ž‘์—…์„ ์‰ฝ๊ฒŒ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Gradle

  • OkHttp๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
dependencies {
    implementation("com.squareup.okhttp3:okhttp:4.9.3")
}
  • ๋™๊ธฐ ์š”์ฒญ
val client = OkHttpClient()

val request = Request.Builder()
    .url("<https://api.example.com>")
    .build()

// ๋™๊ธฐ ์š”์ฒญ
val response: Response = client.newCall(request).execute()
if (response.isSuccessful) {
    println(response.body?.string())
}
  • ๋น„๋™๊ธฐ ์š”์ฒญ
val client = OkHttpClient()

val request = Request.Builder()
    .url("<https://api.example.com>")
    .build()

// ๋น„๋™๊ธฐ ์š”์ฒญ
client.newCall(request).enqueue(object : Callback {
    override fun onFailure(call: Call, e: IOException) {
        e.printStackTrace()
    }

    override fun onResponse(call: Call, response: Response) {
        if (response.isSuccessful) {
            println(response.body?.string())
        }
    }
})

Retrofit

  • Retrofit์€ OkHttp๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋งŒ๋“ค์–ด์ง„ ๊ณ ์ˆ˜์ค€์˜ HTTP ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.
  • REST API ํ˜ธ์ถœ์„ ๋งค์šฐ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค๊ณ„๋˜์—ˆ์œผ๋ฉฐ, JSON ๋ฐ์ดํ„ฐ๋ฅผ ์ž๋™์œผ๋กœ ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™”ํ•˜๊ณ , ์ธํ„ฐํŽ˜์ด์Šค ๊ธฐ๋ฐ˜์œผ๋กœ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ์–ด ์ฝ”๋“œ๊ฐ€ ํ›จ์”ฌ ๊ฐ„๊ฒฐํ•ด์ง‘๋‹ˆ๋‹ค.
  • RxJava๋‚˜ Coroutine์™€ ๊ฐ™์€ ๋น„๋™๊ธฐ ์ž‘์—… ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€๋„ ์‰ฝ๊ฒŒ ํ†ตํ•ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

https://square.github.io/retrofit/

 

Retrofit

A type-safe HTTP client for Android and Java

square.github.io

์ฃผ์š” ๊ธฐ๋Šฅ

  • ์ธํ„ฐํŽ˜์ด์Šค ๊ธฐ๋ฐ˜ ๋„คํŠธ์›Œํฌ ์š”์ฒญ
    • ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ์ •์˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋ฏ€๋กœ ์ฝ”๋“œ๊ฐ€ ๊ฐ„๊ฒฐํ•ฉ๋‹ˆ๋‹ค.
  • ์ž๋™ ์ง๋ ฌํ™” ๋ฐ ์—ญ์ง๋ ฌํ™”
    • JSON ํ˜•์‹์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ž๋™์œผ๋กœ ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜ํ•˜๊ณ , ๊ฐ์ฒด๋ฅผ JSON์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
  • OkHttp ํ†ตํ•ฉ
    • ๋‚ด๋ถ€์ ์œผ๋กœ OkHttp๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
  • ๋น„๋™๊ธฐ ๋„คํŠธ์›Œํฌ ์š”์ฒญ
    • Coroutines, RxJava, Callbacks๋ฅผ ํ†ตํ•ด ๋น„๋™๊ธฐ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ์‰ฝ๊ฒŒ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
  • ์ปค์Šคํ„ฐ๋งˆ์ด์ง•
    • OkHttp์™€ ์–ธํ„ฐ์…‰ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์š”์ฒญ๊ณผ ์‘๋‹ต์„ ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Gradle

  • Retrofit์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
dependencies {
    implementation("com.squareup.retrofit2:retrofit:2.9.0")
    implementation("com.squareup.retrofit2:converter-gson:2.9.0") // JSON ํŒŒ์‹ฑ์šฉ GSON ์ปจ๋ฒ„ํ„ฐ
}

์ธํ„ฐํŽ˜์ด์Šค ์ •์˜

  • ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
interface ApiService {
    @GET("users/{user}")
    suspend fun getUser(@Path("user") userId: String): UserResponse
}

Retrofit ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ ๋ฐ API ํ˜ธ์ถœ

val retrofit = Retrofit.Builder()
    .baseUrl("<https://api.example.com/>")
    .addConverterFactory(GsonConverterFactory.create()) // JSON ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™”
    .build()

val apiService = retrofit.create(ApiService::class.java)

// Coroutines์„ ์‚ฌ์šฉํ•œ API ํ˜ธ์ถœ
GlobalScope.launch {
    val response = apiService.getUser("123")
    println(response)
}

OkHttp vs Retrofit

OkHttp์™€ Retrofit์˜ ์ฐจ์ด์ 

๋ ˆ๋ฒจ ์ €์ˆ˜์ค€์˜ HTTP ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ณ ์ˆ˜์ค€์˜ REST API ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
API ์ •์˜ ๋ฐฉ์‹ ์ง์ ‘ HTTP ์š”์ฒญ ๋ฐ ์‘๋‹ต์„ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•จ ์ธํ„ฐํŽ˜์ด์Šค๋กœ API ์š”์ฒญ์„ ์ •์˜ํ•˜๊ณ  ์ž๋™ ์ฒ˜๋ฆฌ
์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™” ์ง€์›ํ•˜์ง€ ์•Š์Œ (์ง์ ‘ ๊ตฌํ˜„ํ•ด์•ผ ํ•จ) JSON ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™” ์ž๋™ ์ฒ˜๋ฆฌ (Gson ๋“ฑ๊ณผ ํ†ตํ•ฉ)
๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ (enqueue() ์‚ฌ์šฉ) Coroutines ๋ฐ RxJava์™€ ์ž์—ฐ์Šค๋Ÿฌ์šด ํ†ตํ•ฉ ์ง€์›
์ธํ„ฐ์…‰ํ„ฐ ๋„คํŠธ์›Œํฌ ์š”์ฒญ ๋ฐ ์‘๋‹ต์„ ๊ฐ€๋กœ์ฑ„์„œ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ OkHttp์˜ ์ธํ„ฐ์…‰ํ„ฐ ๊ธฐ๋Šฅ์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ
์ฝ”๋“œ ๋ณต์žก๋„ ์ƒ๋Œ€์ ์œผ๋กœ ๋ณต์žกํ•จ (์š”์ฒญ, ์‘๋‹ต, JSON ์ฒ˜๋ฆฌ ๋“ฑ์„ ์ˆ˜๋™์œผ๋กœ ํ•ด์•ผ ํ•จ) ์ƒ๋Œ€์ ์œผ๋กœ ๊ฐ„๋‹จํ•จ (์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ •์˜๋งŒ ํ•˜๋ฉด ์ž๋™ ์ฒ˜๋ฆฌ)

OkHttp๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ?

  • ์ €์ˆ˜์ค€์˜ HTTP ์š”์ฒญ
  • REST API๊ฐ€ ์•„๋‹Œ ๋‹ค๋ฅธ ์œ ํ˜•์˜ ๋„คํŠธ์›Œํฌ ์š”์ฒญ
  • ์š”์ฒญ์˜ ํ—ค๋”๋‚˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ปค์Šคํ…€

Retrofit์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ?

  • RESTful API๋ฅผ ๊ฐ„ํŽธํ•˜๊ฒŒ ํ˜ธ์ถœ
  • JSON ๋ฐ์ดํ„ฐ๋ฅผ ์ž๋™์œผ๋กœ ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™”ํ•  ๋•Œ ์‚ฌ์šฉ
  • ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ์™€ Coroutines, RxJava์™€ ํ†ตํ•ฉ
  • ์ธํ„ฐํŽ˜์ด์Šค ๊ธฐ๋ฐ˜ ๊ฐ€๋…์„ฑ ๋†’์€ ์ฝ”๋“œ

Retorfit๊ณผ OkHttp ๊ฒฐํ•ฉ

  • Retrofit์€ ๋‚ด๋ถ€์ ์œผ๋กœ OkHttp๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ, ํ•„์š”์— ๋”ฐ๋ผ ๊ฒฐํ•ฉํ•˜์—ฌ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • ๋‘ ๋ฐฉ์‹์„ ๊ฒฐํ•ฉํ•˜์—ฌ ํ†ต์‹ ์„ ์ธํ„ฐ์…‰ํŠธ ํ›„ ๋ณ€ํ™˜ํ•˜๋Š” ์ž‘์—…์„ ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
val okHttpClient = OkHttpClient.Builder()
    .addInterceptor { chain ->
        val request = chain.request().newBuilder()
            .addHeader("Authorization", "Bearer token")
            .build()
        chain.proceed(request)
    }
    .build()

val retrofit = Retrofit.Builder()
    .baseUrl("<https://api.example.com/>")
    .client(okHttpClient) // OkHttp ํด๋ผ์ด์–ธํŠธ ์ถ”๊ฐ€
    .addConverterFactory(GsonConverterFactory.create())
    .build()

val apiService = retrofit.create(ApiService::class.java)

๊ฒฐ๋ก 

  • OkHttp๋Š” ์ €์ˆ˜์ค€์—์„œ HTTP ์š”์ฒญ, ์‘๋‹ต์„ ์„ธ๋ฐ€ํ•˜๊ฒŒ ์ œ์–ดํ•˜๋Š” ๊ฒฝ์šฐ ์ ํ•ฉํ•˜๋ฉฐ, ์›น ์†Œ์ผ“, ์ŠคํŠธ๋ฆฌ๋ฐ ๋“ฑ ๋‹ค์–‘ํ•œ HTTP ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • Retrofit์€ RESTful API ํ†ต์‹ ์„ ๊ฐ„ํŽธํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋ฉฐ, JSON ์ง๋ ฌํ™”/์—ญ์ง๋ ฌํ™”, ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ 

https://velog.io/@ilil1/OkHttp-์™€-Retrofit