A question for ktor/thymeleaf integration. Is ther...
# ktor
d
A question for ktor/thymeleaf integration. Is there a relatively straightforward way to enable building composable applications (e.g. I have
foo
and
bar
that can run as their own applications, but I might want to compose them and mount either at
/foo/
and
/bar/
such that context-relative URLs work? More broadly, is there a way to have context-relative URLs work properly using embedded Netty (and not Tomcat) at all? It seems like it is potentially possible with some
StandardLinkBuilder.computeContextPath
shenanigans, but it seems like it would be nicer/more elegant to actually provide an
IContext
implementation (or adapt the existing servlet one..?) Essentially what I’d like is that if I have
@{/location}
in a template defined in
foo
, then when running a standalone application in
foo
, it resolved to
/location
but when `foo`’s routes are mounted inside another application
baz
it resolves to
/foo/location
, or something like that. The Thymeleaf plugin can only be configured once, so perhaps this is just something that needs to be handled with `computeContextPath`…
a
Can you please file an issue or describe your use case in KTOR-1469 if this feature request seems relevant to you?
d
I’m working on a proof of concept implementation of
IWebExchange
and concomitant interfaces (
IWebApplication
,
IWebRequest
,
IWebPrincipal
etc) to see if it’s doable and if so I’ll publish it.
The main hairy bits currently are mapping Ktor’s sessions to
IWebSession
and gracefully handling getting resources when not in a servlet context.
Otherwise, pretty straightforward.
It should be possible to get Thymeleaf to happily behave almost like it’s in a servlet where the context path is
Application.rootPath
(which is what gets set when we are in a servlet context to the context path anyhow).
I’ll reply to KTOR-1469 once I have something working 🙂.
Screenshot 2024-11-20 at 22.49.20.png