if i nest the `router` block inside the `bean` i c...
# spring
n
if i nest the
router
block inside the
bean
i can write:
Copy code
bean {
        val personHandler = PersonHandler(ref())
        router {
            "/person".nest {
                GET("/", personHandler::readAll)
                GET("/{id}", personHandler::readOne)
            }
        }
    }
it compiles but the route is not found at runtime
s
If you're not using Bean definition DSL, you need to inject the handler in the configuration class where the routes are defined. Example can be found on https://github.com/mixitconf/mixit/blob/bad6b92bce6193f9b3f696af9d416c276501dbf1/src/main/kotlin/mixit/web/routes/ApiRoutes.kt#L11
n
thanks that’s what i do but i want to do without the
@Configuration
annotation i stumbled upon that: https://github.com/sdeleuze/spring-kotlin-functional/blob/master/src/main/kotlin/functional/web/Routes.kt then it seems to be assembled like that:
Copy code
bean("webHandler") {
		RouterFunctions.toWebHandler(ref<Routes>().router(), HandlerStrategies.builder().viewResolver(ref()).build())
	}
i removed the second argument because i don’t have views
Copy code
bean("webHandler") {
		RouterFunctions.toWebHandler(ref<Routes>().router())
	}
to no avail...