Philipp Mayer
01/12/2020, 6:36 PMfun routes(indexController: IndexController) = router {
GET("/index", indexController::getIndex)
GET("/uptime", indexController::getUptime)
}
controller:
@Suppress("UNUSED_PARAMETER")
class IndexController(private val indexTemplate: IndexTemplate) {
fun getIndex(req: ServerRequest) = ok().render("index", indexTemplate.index)
and the HTML:
import kotlinx.html.div
import kotlinx.html.dom.create
import kotlinx.html.p
import org.w3c.dom.Document
class IndexTemplate(document: Document) {
val index = document.create.div {
p { +"Hello" }
p { +"you" }
}
}
However, I can't find the way to respond with html.
Unfortunately, sources about the usage of kotlinxhtml and spring are really rare (understandable ofc)