hey guys, when updating to ktor 3.0.0-rc-1
I have a global caching header and few other per route
Copy code
Exception in thread "main" io.ktor.server.application.DuplicatePluginException: Please make sure that you use unique name for the plugin and don't install it twice. Plugin `Caching Headers` is already installed to the pipeline
fun Application.caching() {
install(CachingHeaders)
}
fun Routing.cachedRoute(
maxAgeSeconds: Int
) {
install(CachingHeaders) {
options { _, _ -> CachingOptions(CacheControl.MaxAge(maxAgeSeconds = maxAgeSeconds)) }
}
}
i have these simple helper functions, pretty self explanatory
Hristijan
09/10/2024, 6:47 PM
if i remove the
Routing.cachedRoute
from my routes, it’s okay, it works
a
Aleksei Tirman [JB]
09/10/2024, 7:00 PM
I get the following exception when calling them for the application and routing respectively:
Copy code
Exception in thread "main" io.ktor.server.application.DuplicatePluginException: Installing RouteScopedPlugin to application and route is not supported. Consider moving application level install to routing root.
thank you color 1
Aleksei Tirman [JB]
09/10/2024, 7:00 PM
Here is the code:
Copy code
fun main() {
embeddedServer(Netty, port = 8081, host = "127.0.0.1") {
caching()
routing {
cachedRoute(100)
}
}.start(wait = true)
}