Funny that I have to start a whole application for...
# ktor
d
Funny that I have to start a whole application for this though, on one hand it's more flexible, but it means re-installing all the same features for both, etc... it might have been nice to have
Copy code
routing { port(8080) { ... } ; port(9090) { ...} }
?
d
What about this?
Copy code
fun main(args: Array<String>) {
    embeddedServer(Netty, port = 8080, module = Application::apiModule).start(wait = false)
    embeddedServer(Netty, port = 9090, module = Application::internalModule).start(wait = true)
}

fun Application.apiModule() {
	common()
	routing {
		// specific for the api
	}
}

fun Application.internalModule() {
	common()
	routing {
		// specific for internal
	}
}

fun Application.common() {
	routing {
		// for both services
	}
}
d
That's what I thought, but one Netty instance can't listen on two ports and redirect accordingly, in Vert.x I don't think I had to start a webserver for each port... But then, I don't know that much about Netty internals (I'm coming from Php/nginx...)
c
Note that you can check incoming port via
call.request.local.port
(for example, you can install an interceptor on specific route to ensure that the port is right)
d
This could be how a
routing { port(8080) { ... } ; port(9090) { ...} }
could be implemented... ? But then there's only one port param for
embeddedServer
...