ktorio / ktor

Framework for quickly creating connected applications in Kotlin with minimal effort
https://ktor.io
Apache License 2.0
12.81k stars 1.04k forks source link

combine ktor with Wicket #270

Open kutoman opened 6 years ago

kutoman commented 6 years ago

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)

cy6erGn0m commented 6 years ago

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?

kutoman commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.

oleg-larshin commented 4 years ago

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