Adam S
09/03/2022, 4:56 PMCannot GET /servers/test-server
I've set up the routing...
fun init() {
routing
.on("/", { _ ->
println("routing.on HOME")
homepageView()
})
.on("/servers/(.*)", { match ->
println("routing.on SERVER $match")
val serverId = match.data[0] as? String ?: error("invalid server id")
println("routing.on SERVER serverId:$serverId")
serverView(serverId)
}
)
.resolve()
}
And I think I'm creating the link correctly
listTag(ListType.UL) {
state.serverIds.forEach { serverId ->
li {
div {
link(
label = "$serverId",
dataNavigo = true,
url = "/servers/$serverId",
)
}
}
}
}
I can see in the logs that Navigo seems to be aware of the routes, and is printing routing.on HOME
, but it never prints routing.on SERVER
[WebsocketService] init <ws://localhost:3000/kafkatorio/ws>,
kotlin-kotlin-stdlib-js-ir.js?46ac:19385 routing.on HOME
index.js?0118:551 [webpack-dev-server] Hot Module Replacement enabled.
index.js?0118:551 [webpack-dev-server] Live Reloading enabled.
kotlin-kotlin-stdlib-js-ir.js?46ac:19385 [WebsocketService.handleMessageEvent] non-json message elapsed 2h 53m 46.078512299s
test-server:1 GET <http://localhost:3000/servers/test-server> 404 (Not Found)
Navigated to <http://localhost:3000/servers/test-server>
I've tried using different matcher styles (regex, path IDs, plain strings) but nothing seems to work.
A full example might help. The best example I've found was here: https://github.com/rjaros/kvision-realworld-example-app-fullstack/, but that's using the older version of Navigo. There's another usage in the KVision examples repo, but it's more simplistic.Adam S
09/03/2022, 6:50 PMmain().bind(siteStateStore) { state ->
div(className = "container-fluid") {
when (state.view) {
SiteView.HOME -> homePage(state)
SiteView.SERVER -> serverPage(state)
}
}
window.setTimeout({ routing.updatePageLinks() }, 0)
}
}