@@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicReference
19
19
* in that an existing Ktor client can be passed, and config is applied to that.
20
20
*/
21
21
object KtorClientFactory {
22
- // Function to create an HttpClient with configuration and optional session token
23
22
fun create (
24
23
httpClient : HttpClient = HttpClient (CIO ),
25
24
sessionToken : String? = null,
@@ -28,15 +27,13 @@ object KtorClientFactory {
28
27
return configureHttpClient(httpClient, sessionToken, configBlock)
29
28
}
30
29
31
- // Function to create a new HttpClient based on an existing HttpClient configuration
32
30
fun createWithExistingConfig (
33
31
existingClient : HttpClient ,
34
32
sessionToken : String? = null
35
33
): HttpClient {
36
- return configureHttpClient(existingClient, sessionToken) // Reapply session token while retaining existing config
34
+ return configureHttpClient(existingClient, sessionToken)
37
35
}
38
36
39
- // Function to configure the HttpClient
40
37
private fun configureHttpClient (
41
38
baseClient : HttpClient ,
42
39
sessionToken : String? = null,
@@ -45,7 +42,7 @@ object KtorClientFactory {
45
42
return baseClient.config {
46
43
defaultRequest {
47
44
url(Config .apiBaseUrl)
48
- sessionToken?.let { headers.append(" X-Session-Token" , it) } // Apply session token if present
45
+ sessionToken?.let { headers.append(" X-Session-Token" , it) }
49
46
headers.appendIfNameAbsent(HttpHeaders .ContentType , " application/json" )
50
47
}
51
48
expectSuccess = true
@@ -58,7 +55,7 @@ object KtorClientFactory {
58
55
install(UserAgent ) {
59
56
agent = Config .userAgent
60
57
}
61
- configBlock() // Apply additional user-defined config
58
+ configBlock()
62
59
}
63
60
}
64
61
}
0 commit comments