<@U48UFKPL1> you could also maybe do something lik...
# http4k
d
@Luis Mirabal you could also maybe do something like this with Kotlin delegation, which would allow you to selectively override bits of behaviour. It's possibly a bit stylistic, but it will work with minimal fuss - whether or not it's better than just implementing a composite server is probably for you to decide! 🙂
Copy code
import org.http4k.core.HttpHandler
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.server.Http4kServer
import org.http4k.server.Undertow

fun UndertowAndMessaging(port: Int, handler: HttpHandler): Http4kServer =
    with(Undertow(port).toServer(handler)) {
        object : Http4kServer by this {
            override fun start() = this@with.start().apply {
                // start message broker here...
            }
        }
    }

fun main() {
    val app: HttpHandler = { Response(OK) }
    UndertowAndMessaging(9000, app).start()
}