Hello, I am writing a Plugin in Ktor, the idea of this Plugin is to first check if Internet is available, if not cancel request and throw error, and when we receive response we check if the status is
401
in that case retry the call after making a new token.
scope.requestPipeline.intercept(HttpRequestPipeline.State) {
println("MyNewPlugin : works the scope ${context.method}")
context.header(HttpHeaders.UserAgent, feature.agent)
}
scope.responsePipeline.intercept(HttpRequestPipeline.State) {
println("MyNewPlugin : works the scope ${context.response.status}")
}
I wrote this in the
install
function to test the Plugin for request and response pipeline but it crashes with this error
Caused by: io.ktor.util.pipeline.InvalidPhaseException: Phase Phase('State') was not registered for this pipeline