Nicodemus Ojwee

12/16/2020, 9:15 AM
Hello everyone. I am trying to load an HTML thymeleaf template from resources and pass data to it using coRouter {} in spring boot i don't see any example online. Has anyone done it yet? If so then help with a code snippet on how i can achieve this. I have seen an example of something similar to the above in java like below.
public RouterFunction<ServerResponse> htmlRouter(
  @Value("classpath:/public/index.html") Resource html) {
    return route(GET("/"), request
      -> ok().contentType(MediaType.TEXT_HTML).syncBody(html)
I have figured it out. This is how i am implementing it.
    fun htmlRouter() = coRouter {
        GET("/web/fees") {
            val model: Map<String, Any> = HashMap()
                .renderAndAwait("template", model)