Server Plugin
關閉 URL
程式碼範例: shutdown-url
ShutDownUrl 外掛程式可讓你設定用於關閉伺服器的 URL。 啟用此外掛程式有兩種方式:
在設定檔中設定關閉 URL
你可以在設定檔中使用 ktor.deployment.shutdown.url 屬性來設定關閉 URL。
shell
ktor {
deployment {
shutdown.url = "/shutdown"
}
}yaml
ktor:
deployment:
shutdown:
url: "/shutdown"透過安裝外掛程式設定關閉 URL
若要在程式碼中安裝並設定關閉 URL,請將 ShutDownUrl.ApplicationCallPlugin 傳遞給 install 函式,並使用 shutDownUrl 屬性:
kotlin
install(ShutDownUrl.ApplicationCallPlugin) {
shutDownUrl = "/shutdown"
exitCodeSupplier = { 0 }
}如需完整範例,請參閱 shutdown-url。
