ktor icon indicating copy to clipboard operation
ktor copied to clipboard

combine ktor with Wicket

Open kutoman opened this issue 6 years ago • 5 comments

I would like to use Apache Wicket's component based approach in a ktor server. I'm trying to integrate a wicket application which should make my web ui component based in an embedded ktor server but I'm not sure how to manage this. Here is the code I would like to combine with a io.ktor.server.engine.embeddedServer call (if it's possible)

kutoman avatar Dec 04 '17 13:12 kutoman

Correct me if I am wrong but I don't see any value of using ktor with Wicket. Can't you simply use Kotlin with Wicket with no ktor? Why combine?

cy6erGn0m avatar Dec 05 '17 15:12 cy6erGn0m

imho there is a value. My server has to provide both a web ui (for my backend) and a well documented api (for frontend clients). By using ktor it's pretty easy for me to implement the api and document it (by using ktor-locations and swagger). I think this is not straightforward in wicket. But on the other hand wicket is a good fit for creating the web ui. Its component based nature makes the ui easy to maintain which is missing in ktor. Hence a combination would help me alot.

kutoman avatar Dec 05 '17 18:12 kutoman

I found out that the wicket application can be run without a web.xml. Thus, if possible, I just would need to add the application as a HttpServlet to ktor.

kutoman avatar Dec 06 '17 08:12 kutoman

I've got this here:

embeddedServer(Jetty, 8080, configure = {

    configureServer = server@ {

        this.handler = WebAppContext().apply {
            server = this@server
            contextPath = "/"
            war = "src/main/webapp"
        }
    }

}) {

    install(DefaultHeaders)
    install(CallLogging)
}.start(true)

this is of course not working, since the handler gets replaced by a JettyKtorHandler later on before the server gets started. Any possibility to have multiple handlers here, or do I have to write my custom engine?

Note: unfortunately I can't reuse JettyKtorHandler since it's an internal class. Thus implementing a customized ApplicationEngine won't work without a lot code duplication.

kutoman avatar Dec 13 '17 08:12 kutoman

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

oleg-larshin avatar Aug 10 '20 15:08 oleg-larshin