Notice
Recent Posts
Recent Comments
Link
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발자이야기

Retrofit2 url이 만들어지는 패턴 본문

android

Retrofit2 url이 만들어지는 패턴

개발자가되고싶어 2020. 6. 2. 11:34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 
interface RetroApi {
    @GET("test")
    fun getTest() : Call<String>
}
 
 
fun getInstnace() : Retrofit {
    if(instance == null){
        instance = Retrofit.Builder()
                .baseUrl("http://www.naver.com/cafe/id")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
    }
    return instance!!
}
 
만들어지는 url = "http://www.naver.com/cafe/test"
 
-------------------------------------------------------------------------
 
interface RetroApi {
    @GET("test")
    fun getTest() : Call<String>
}
 
fun getInstnace() : Retrofit {
    if(instance == null){
        instance = Retrofit.Builder()
                .baseUrl("http://www.naver.com/cafe/id/")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
    }
    return instance!!
}
 
만들어지는 url = "http://www.naver.com/cafe/id/test"
 
-------------------------------------------------------------------------
 
interface RetroApi {
    @GET("/test")
    fun getTest() : Call<String>
}
 
fun getInstnace() : Retrofit {
    if(instance == null){
        instance = Retrofit.Builder()
                .baseUrl("http://www.naver.com/cafe/id")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
    }
    return instance!!
}
 
만들어지는 url = "http://www.naver.com/test"
 
 
 
 
 
 
 
 
 
 
 
cs

'android' 카테고리의 다른 글

mvvm + dagger  (0) 2021.06.07
android AAC LiveData - switchMap, map  (0) 2021.05.28
dagger @binds 어노테이션  (1) 2021.05.23
의존성주입(DI) android dagger  (0) 2021.05.22
android recyclerview diffutil  (0) 2021.05.14