https://kotlinlang.org logo
#arrow
Title
# arrow
d

dave08

03/30/2023, 7:17 AM
In the Ktor
server()
function in suspendApp library, is there a way to add a
connector { }
for an internal port?
s

simon.vergauwen

03/30/2023, 7:27 AM
It exposes the exact same API as the original
embeddedServer
API from Ktor except as an extension on
ResourceScope
.
d

dave08

03/30/2023, 7:38 AM
There's a bunch of overrides to that api... one of them is:
Copy code
CoroutineScope.embeddedServer(
    factory: ApplicationEngineFactory<TEngine, TConfiguration>,
    vararg connectors: EngineConnectorConfig = arrayOf(EngineConnectorBuilder()),
    watchPaths: List<String> = listOf(WORKING_DIRECTORY_PATH),
    parentCoroutineContext: CoroutineContext = EmptyCoroutineContext,
    configure: TConfiguration.() -> Unit = {},
    module: Application.() -> Unit
): TEngine
and another one receives a
applicationEngineEnvironment
... those can configure multiple connectors... but the one you wrap only provides one port.
s

simon.vergauwen

03/30/2023, 7:39 AM
Then it should be added to SuspendApp Ktor
d

dave08

03/30/2023, 7:40 AM
Yeah. I could just write my own, though I'd suppose more people could benefit from this 😊.
Oh... can't just copy and alter the existing implementation:
Another reason to have in in suspendApp 🙈
A PR to SuspendApp would be greatly appreciated.
d

dave08

03/30/2023, 7:44 AM
I could see if I have a bit of time (a bit too much to do now...), but how could I get around this meanwhile?
Well, I guess I'd give up on that watchPaths for now then...
39 Views