I want to achieve the following in Ktor server and...
# ktor
d
I want to achieve the following in Ktor server and found only a imho hacky solution (for a demo app, not for production...): • Use the shutdown url plugin to shutdown the application • Protect the shutdown url with the Authentication plugin (with basic auth) Is there an obvious and clean way to do it? Had some ideas like: • Changing the order of plugin install and route definition. -> Didn't work. Imho because the shutdown url plugin is registered for
EnginePipeline.Before
so the install order doesn't matter, it's always called before the the routing is done • Custom plugin that calls the auth and then shutdown: -> Does this even work? Does it require copying code from the other two plugins? Also not really what I want My hack solution so far: • Create route with
authenticate
for the shutdown route • Install the shutdown url plugin inside the body the GET of that route • Use respondRedirect to redirect to the shutdown url (would be infinite redirect, but the shutdown url plugin is triggered instead)
The hacky solution....kt
a
You can find a solution here.
d
Ah didn't find the question and your answer on SO. Also, totally forgot to use ShutDownUrl class without the plugin. That's exactly what I was looking for. Thanks for the info!