aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-12 18:22:43 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-12 18:22:43 +0200
commitbcf7504392baccf1568e740c1d453eac7080fb5b (patch)
tree519489751032814bfc0d5426c48de257b788329f /kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft
parent28b6e9d646123d774660ebdf0124eeb8a22fe087 (diff)
downloadkvision-bcf7504392baccf1568e740c1d453eac7080fb5b.tar.gz
kvision-bcf7504392baccf1568e740c1d453eac7080fb5b.tar.bz2
kvision-bcf7504392baccf1568e740c1d453eac7080fb5b.zip
Redesign spring-boot server module to use Spring WebFlux instead of Spring MVC.
Diffstat (limited to 'kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft')
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt22
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt8
2 files changed, 21 insertions, 9 deletions
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index 7ccd6341..36a7897e 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -21,6 +21,7 @@
*/
package pl.treksoft.kvision.remote
+import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import io.ktor.application.ApplicationCall
import io.ktor.application.call
@@ -49,6 +50,12 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import pl.treksoft.kvision.types.*
+import java.time.LocalDate
+import java.time.LocalDateTime
+import java.time.LocalTime
+import java.time.OffsetDateTime
+import java.time.OffsetTime
import kotlin.reflect.KClass
/**
@@ -73,7 +80,20 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
val webSocketRequests: MutableMap<String, suspend WebSocketServerSession.() -> Unit> =
mutableMapOf()
- val mapper = jacksonObjectMapper()
+ val mapper = jacksonObjectMapper().apply {
+ val module = SimpleModule()
+ module.addSerializer(LocalDateTime::class.java, LocalDateTimeSerializer())
+ module.addSerializer(LocalDate::class.java, LocalDateSerializer())
+ module.addSerializer(LocalTime::class.java, LocalTimeSerializer())
+ module.addSerializer(OffsetDateTime::class.java, OffsetDateTimeSerializer())
+ module.addSerializer(OffsetTime::class.java, OffsetTimeSerializer())
+ module.addDeserializer(LocalDateTime::class.java, LocalDateTimeDeserializer())
+ module.addDeserializer(LocalDate::class.java, LocalDateDeserializer())
+ module.addDeserializer(LocalTime::class.java, LocalTimeDeserializer())
+ module.addDeserializer(OffsetDateTime::class.java, OffsetDateTimeDeserializer())
+ module.addDeserializer(OffsetTime::class.java, OffsetTimeDeserializer())
+ this.registerModule(module)
+ }
var counter: Int = 0
/**
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt
index 693c8e3c..cc77f341 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt
@@ -25,7 +25,6 @@ import io.ktor.application.ApplicationCall
import io.ktor.sessions.get
import io.ktor.sessions.sessions
import kotlinx.serialization.Serializable
-import kotlinx.serialization.Transient
/**
* A user profile.
@@ -41,7 +40,6 @@ actual data class Profile(
val remembered: Boolean = false,
val clientName: String? = null
) {
- @Transient
var username: String?
get() = attributes["username"]
set(value) {
@@ -51,7 +49,6 @@ actual data class Profile(
attributes.remove("username")
}
}
- @Transient
var firstName: String?
get() = attributes["first_name"]
set(value) {
@@ -61,7 +58,6 @@ actual data class Profile(
attributes.remove("first_name")
}
}
- @Transient
var familyName: String?
get() = attributes["family_name"]
set(value) {
@@ -71,7 +67,6 @@ actual data class Profile(
attributes.remove("family_name")
}
}
- @Transient
var displayName: String?
get() = attributes["display_name"]
set(value) {
@@ -81,7 +76,6 @@ actual data class Profile(
attributes.remove("display_name")
}
}
- @Transient
var email: String?
get() = attributes["email"]
set(value) {
@@ -91,7 +85,6 @@ actual data class Profile(
attributes.remove("email")
}
}
- @Transient
var pictureUrl: String?
get() = attributes["picture_url"]
set(value) {
@@ -101,7 +94,6 @@ actual data class Profile(
attributes.remove("picture_url")
}
}
- @Transient
var profileUrl: String?
get() = attributes["profile_url"]
set(value) {