diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-02-16 02:39:44 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-02-16 02:39:44 +0100 |
commit | 7120b09bfebb7ab0c562c6b5db7d63a1b9a772d5 (patch) | |
tree | 122a103b94b7d990b6956aa169c4d8f9af171c5b /kvision-modules/kvision-server-spring-boot | |
parent | f1bbb0293b795f192fdef6e3ac8fc465232838d1 (diff) | |
download | kvision-7120b09bfebb7ab0c562c6b5db7d63a1b9a772d5.tar.gz kvision-7120b09bfebb7ab0c562c6b5db7d63a1b9a772d5.tar.bz2 kvision-7120b09bfebb7ab0c562c6b5db7d63a1b9a772d5.zip |
Refactor main controller for Spring Boot. Enable auto-configuration.
Diffstat (limited to 'kvision-modules/kvision-server-spring-boot')
3 files changed, 4 insertions, 30 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 da47c750..f8006857 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 @@ -33,7 +33,7 @@ import javax.servlet.http.HttpServletResponse open class KVController { @Autowired - lateinit var kvServer: KVServer + lateinit var services: List<KVServiceManager<*>> @Autowired lateinit var applicationContext: ApplicationContext @@ -44,7 +44,7 @@ open class KVController { ) open fun kVMapping(req: HttpServletRequest, res: HttpServletResponse) { val routeUrl = req.requestURI - val route = kvServer.services.mapNotNull { + val route = services.mapNotNull { when (req.method) { "GET" -> it.getRequests[routeUrl] "POST" -> it.postRequests[routeUrl] @@ -61,4 +61,4 @@ open class KVController { } } -} +}
\ No newline at end of file diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt deleted file mode 100644 index e8dee5cc..00000000 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2017-present Robert Jaros - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package pl.treksoft.kvision.remote - -/** - * A Spring boot based server. - */ -open class KVServer(val services: List<KVServiceManager<*>>) diff --git a/kvision-modules/kvision-server-spring-boot/src/main/resources/META-INF/spring.factories b/kvision-modules/kvision-server-spring-boot/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..e31ff24d --- /dev/null +++ b/kvision-modules/kvision-server-spring-boot/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=pl.treksoft.kvision.remote.KVController |