Robert Jaros
03/15/2024, 12:02 PMsingePageApplication()
, but with a server generated index.html
. I've created this configuration:
routing {
get("/index.html") {
call.respondText(
"<html><head><title>Custom index.html</title></head><body></body></html>",
ContentType.Text.Html
)
}
singlePageApplication {
defaultPage = "index.html"
filesPath = "/assets"
useResources = true
}
}
but unfortunately it doesn't work (not existing urls are redirected to /assets/index.html
file instead of my /index.html
endpoint). Can I somehow do this with a simple configuration or do I have to implement the whole thing from scratch?Aleksei Tirman [JB]
03/15/2024, 1:35 PM/index.html
route's handler in your application?Robert Jaros
03/15/2024, 2:18 PMAleksei Tirman [JB]
03/15/2024, 2:20 PMRobert Jaros
03/15/2024, 3:09 PMrouting {
get("/index.html") {
call.respondText("Hello, world!", ContentType.Text.Plain)
}
singlePageApplication {
defaultPage = "NOT_EXISTING_RESOURCE"
filesPath = "/assets"
useResources = true
}
route("/") {
route("{static-content-path-parameter...}") { // !!! Important name copied from Ktor sources
get {
call.respondText("Hello, world!", ContentType.Text.Plain)
}
}
}
}
It seems to do exactly what I want.