mirror of https://github.com/usbharu/Hideout.git
feat: ContentNegotiationを追加
This commit is contained in:
parent
5320915f7f
commit
4a66307d24
|
@ -46,12 +46,14 @@ dependencies {
|
||||||
implementation("io.insert-koin:koin-core:$koin_version")
|
implementation("io.insert-koin:koin-core:$koin_version")
|
||||||
implementation("io.insert-koin:koin-ktor:$koin_version")
|
implementation("io.insert-koin:koin-ktor:$koin_version")
|
||||||
implementation("io.insert-koin:koin-logger-slf4j:$koin_version")
|
implementation("io.insert-koin:koin-logger-slf4j:$koin_version")
|
||||||
|
implementation("io.ktor:ktor-client-logging-jvm:2.2.4")
|
||||||
|
|
||||||
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
|
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
||||||
|
|
||||||
implementation("io.ktor:ktor-client-core:$ktor_version")
|
implementation("io.ktor:ktor-client-core:$ktor_version")
|
||||||
implementation("io.ktor:ktor-client-cio:$ktor_version")
|
implementation("io.ktor:ktor-client-cio:$ktor_version")
|
||||||
|
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
jib {
|
jib {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package dev.usbharu.hideout
|
package dev.usbharu.hideout
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude
|
import com.fasterxml.jackson.annotation.JsonInclude
|
||||||
import com.fasterxml.jackson.core.JsonGenerator
|
feat:import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import dev.usbharu.hideout.config.Config
|
import dev.usbharu.hideout.config.Config
|
||||||
import dev.usbharu.hideout.config.ConfigData
|
import dev.usbharu.hideout.config.ConfigData
|
||||||
|
@ -15,9 +14,10 @@ import dev.usbharu.hideout.routing.*
|
||||||
import dev.usbharu.hideout.service.*
|
import dev.usbharu.hideout.service.*
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.engine.cio.*
|
import io.ktor.client.engine.cio.*
|
||||||
|
import io.ktor.client.plugins.contentnegotiation.*
|
||||||
|
import io.ktor.client.plugins.logging.*
|
||||||
|
import io.ktor.serialization.jackson.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.auth.*
|
|
||||||
import io.ktor.util.*
|
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
import org.koin.ktor.ext.inject
|
import org.koin.ktor.ext.inject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -39,10 +39,25 @@ fun Application.module() {
|
||||||
url = environment.config.propertyOrNull("hideout.url")?.getString()
|
url = environment.config.propertyOrNull("hideout.url")?.getString()
|
||||||
?: environment.config.property("hideout.hostname").getString(),
|
?: environment.config.property("hideout.hostname").getString(),
|
||||||
objectMapper = jacksonObjectMapper().enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
objectMapper = jacksonObjectMapper().enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
||||||
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false)
|
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||||
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
single<HttpClient> { HttpClient(CIO) }
|
single<HttpClient> {
|
||||||
|
HttpClient(CIO) {
|
||||||
|
install(ContentNegotiation) {
|
||||||
|
jackson {
|
||||||
|
enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
||||||
|
setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||||
|
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
install(Logging) {
|
||||||
|
logger = Logger.DEFAULT
|
||||||
|
level = LogLevel.HEADERS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
single<IUserRepository> { UserRepository(get()) }
|
single<IUserRepository> { UserRepository(get()) }
|
||||||
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
||||||
single<IUserAuthService> { UserAuthService(get(), get()) }
|
single<IUserAuthService> { UserAuthService(get(), get()) }
|
||||||
|
|
Loading…
Reference in New Issue