public fun defaultEnginePipeline()

in ktor-server/ktor-server-host-common/jvm/src/io/ktor/server/engine/DefaultEnginePipeline.kt [25:62]


public fun defaultEnginePipeline(environment: ApplicationEnvironment): EnginePipeline {
    val pipeline = EnginePipeline()

    environment.config.propertyOrNull("ktor.deployment.shutdown.url")?.getString()?.let { url ->
        pipeline.install(ShutDownUrl.EngineFeature) {
            shutDownUrl = url
        }
    }

    pipeline.intercept(EnginePipeline.Call) {
        try {
            call.application.execute(call)
            if (call.response.status() == null) {
                call.respond(HttpStatusCode.NotFound)
            }
        } catch (error: ChannelIOException) {
            with(CallLogging.Internals) {
                withMDCBlock {
                    call.application.environment.logFailure(call, error)
                }
            }
        } catch (error: Throwable) {
            with(CallLogging.Internals) {
                withMDCBlock {
                    call.application.environment.logFailure(call, error)
                    handleFailure(error)
                }
            }
        } finally {
            try {
                call.request.receiveChannel().discard()
            } catch (ignore: Throwable) {
            }
        }
    }

    return pipeline
}