-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ktor-internal): add uts and remove to correct package.
- Loading branch information
Showing
6 changed files
with
86 additions
and
56 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
common/src/commonMain/kotlin/com/tddworks/common/network/api/ktor/internal/AuthConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.tddworks.common.network.api.ktor.internal | ||
|
||
data class AuthConfig( | ||
val authToken: (() -> String)? = null | ||
) |
9 changes: 9 additions & 0 deletions
9
common/src/commonMain/kotlin/com/tddworks/common/network/api/ktor/internal/ClientFeatures.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tddworks.common.network.api.ktor.internal | ||
|
||
import kotlinx.serialization.json.Json | ||
|
||
data class ClientFeatures( | ||
val json: Json = Json, | ||
val queryParams: Map<String, String> = emptyMap(), | ||
val expectSuccess: Boolean = true | ||
) |
28 changes: 28 additions & 0 deletions
28
...n/src/commonMain/kotlin/com/tddworks/common/network/api/ktor/internal/ConnectionConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.tddworks.common.network.api.ktor.internal | ||
|
||
import io.ktor.client.plugins.* | ||
import io.ktor.http.* | ||
|
||
interface ConnectionConfig { | ||
fun setupUrl(builder: DefaultRequest.DefaultRequestBuilder) { | ||
builder.setupUrl(this) | ||
} | ||
} | ||
|
||
private fun DefaultRequest.DefaultRequestBuilder.setupUrl(connectionConfig: ConnectionConfig) { | ||
when (connectionConfig) { | ||
is HostPortConnectionConfig -> { | ||
url { | ||
protocol = | ||
connectionConfig.protocol()?.let { URLProtocol.createOrDefault(it) } | ||
?: URLProtocol.HTTPS | ||
host = connectionConfig.host() | ||
connectionConfig.port()?.let { port = it } | ||
} | ||
} | ||
|
||
is UrlBasedConnectionConfig -> { | ||
connectionConfig.baseUrl().let { url.takeFrom(it) } | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...mmonMain/kotlin/com/tddworks/common/network/api/ktor/internal/HostPortConnectionConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tddworks.common.network.api.ktor.internal | ||
|
||
data class HostPortConnectionConfig( | ||
val protocol: () -> String? = { null }, | ||
val host: () -> String = { "" }, | ||
val port: () -> Int? = { null }, | ||
) : ConnectionConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters