aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-02-01 11:28:13 +0100
committerRobert Jaros <rjaros@finn.pl>2019-02-01 11:28:13 +0100
commitcf0a609fc42b2356f50f32e03f02e2ace0d46e35 (patch)
tree948acd9e74b893046317a764ddbfba45d3d87a36
parentab2b183792f061f1292f77931ca2a36c62986141 (diff)
downloadkvision-cf0a609fc42b2356f50f32e03f02e2ace0d46e35.tar.gz
kvision-cf0a609fc42b2356f50f32e03f02e2ace0d46e35.tar.bz2
kvision-cf0a609fc42b2356f50f32e03f02e2ace0d46e35.zip
Refactor KVController
-rw-r--r--kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVController.kt7
1 files changed, 3 insertions, 4 deletions
diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVController.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVController.kt
index 128933f2..50544dc1 100644
--- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVController.kt
+++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVController.kt
@@ -39,17 +39,16 @@ open class KVController {
method = [RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE, RequestMethod.OPTIONS]
)
open fun kVMapping(req: HttpServletRequest, res: HttpServletResponse) {
- val method = req.method
val routeUrl = req.requestURI
- val route = kvServer.services.map {
- when (method) {
+ val route = kvServer.services.mapNotNull {
+ when (req.method) {
"POST" -> it.postRequests[routeUrl]
"PUT" -> it.putRequests[routeUrl]
"DELETE" -> it.deleteRequests[routeUrl]
"OPTIONS" -> it.optionsRequests[routeUrl]
else -> null
}
- }.find { it != null }
+ }.firstOrNull()
if (route != null) {
route.invoke(req, res)
} else {