dave08
11/11/2018, 2:23 PMwithTestApplication
and multiple connectors (and testing on port), how will the test know how to request from a particular port?dave08
11/11/2018, 3:31 PMfun TestApplicationEngine.handleRequest(
method: HttpMethod,
port: Int = 80,
uri: String,
setup: TestApplicationRequest.() -> Unit = {}
): TestApplicationCall = handleRequest {
this.uri = uri
this.method = method
this.addHeader(HttpHeaders.Host, "localhost:$port")
setup()
}
Shouldn't it be added to Ktor?cy
11/12/2018, 12:52 PMdave08
11/12/2018, 12:55 PMdata class HttpPortRouteSelector(val port: Int) : RouteSelector(RouteSelectorEvaluation.qualityParameter) {
override fun evaluate(context: RoutingResolveContext, segmentIndex: Int): RouteSelectorEvaluation {
if (context.call.request.local.port == port)
return RouteSelectorEvaluation.Constant
return RouteSelectorEvaluation.Failed
}
override fun toString(): String = "(port:$port)"
}
@ContextDsl
fun Route.port(port: Int, build: Route.() -> Unit): Route {
val selector = HttpPortRouteSelector(port)
return createChild(selector).apply(build)
}
Should I include it in the same ticket or open a new one for this? Also it might be nice to include support for declaring multiple ports in Hocon and embeddedServer configs...dave08
11/12/2018, 12:57 PMdave08
11/12/2018, 12:58 PMdave08
11/12/2018, 1:13 PMdave08
11/12/2018, 2:43 PM