diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-02-01 11:28:13 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-02-01 11:28:13 +0100 |
commit | cf0a609fc42b2356f50f32e03f02e2ace0d46e35 (patch) | |
tree | 948acd9e74b893046317a764ddbfba45d3d87a36 /kvision-modules/kvision-server-spring-boot/src/main/kotlin | |
parent | ab2b183792f061f1292f77931ca2a36c62986141 (diff) | |
download | kvision-cf0a609fc42b2356f50f32e03f02e2ace0d46e35.tar.gz kvision-cf0a609fc42b2356f50f32e03f02e2ace0d46e35.tar.bz2 kvision-cf0a609fc42b2356f50f32e03f02e2ace0d46e35.zip |
Refactor KVController
Diffstat (limited to 'kvision-modules/kvision-server-spring-boot/src/main/kotlin')
-rw-r--r-- | kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVController.kt | 7 |
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 { |