Skip to content

Commit

Permalink
Merge branch 'main' into fix/thread-safe-auth-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
thebino authored Dec 14, 2022
2 parents 05910c4 + 130be9a commit 0f65044
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions data/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ kotlin {
implementation(libs.io.ktor.client.serialization)
implementation(libs.io.ktor.serialization.kotlinx.json)
implementation(libs.io.ktor.client.content.negotiation)
implementation(libs.io.ktor.client.logging)
implementation(libs.org.jetbrains.kotlinx.serialization.json)
implementation(libs.io.insert.koin.core)
implementation(libs.io.github.aakira.napier)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
*/
package social.androiddev.common.network.di

import io.github.aakira.napier.DebugAntilog
import io.github.aakira.napier.Napier
import io.ktor.client.HttpClient
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.Logging
import io.ktor.http.URLProtocol
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
Expand All @@ -26,9 +31,18 @@ import social.androiddev.common.network.MastodonApiKtor
* network/api related classes
*/
val networkModule: Module = module {

singleOf<HttpClient> {
HttpClient {
install(Logging) {
logger = object : Logger {
override fun log(message: String) {
Napier.v(message, null, "HttpClient")
}
}
level = LogLevel.BODY
// todo: provide different antilog for release
Napier.base(DebugAntilog())
}
// install plugin so we can use type-safe data models for serialization in ktor
install(ContentNegotiation) {
json(
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ org-xerial = "3.8.10.2"
io-insert-koin = "3.2.0"
com-russhwolf = "1.0.0-RC"
kotlinx-serialization = "1.4.0"
io-github-aakira = "2.6.1"

[libraries]
# plugins
Expand All @@ -40,6 +41,7 @@ io-ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-neg
io-ktor-client-mock-jvm = { module = "io.ktor:ktor-client-mock-jvm", version.ref = "io-ktor" }
io-ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "io-ktor" }
io-ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "io-ktor" }
io-ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "io-ktor" }
io-insert-koin-core = { module = "io.insert-koin:koin-core", version.ref = "io-insert-koin" }
io-insert-koin-test = { module = "io.insert-koin:koin-test", version.ref = "io-insert-koin" }
io-insert-koin-android = { module = "io.insert-koin:koin-android", version.ref = "io-insert-koin" }
Expand Down Expand Up @@ -68,5 +70,6 @@ com-arkivanov-decompose-extensions-compose-jetbrains = { module = "com.arkivanov
com-arkivanov-decompose-extensions-compose-jetpack = { module = "com.arkivanov.decompose:extensions-compose-jetpack", version.ref = "com-arkivanov-decompose" }
multiplatform-settings = { module = "com.russhwolf:multiplatform-settings", version.ref = "com-russhwolf" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
io-github-aakira-napier = { module = "io.github.aakira:napier", version.ref = "io-github-aakira" }

[plugins]

0 comments on commit 0f65044

Please sign in to comment.