Can you install the same `RouteScopedPlugin` with ...
# ktor
c
Can you install the same
RouteScopedPlugin
with different configuration on individual routes with different methods? I have a plugin that does the authorization for my routes similar to the example custom-plugin-authorization but I can't install the plugin with different configuration for different methods
Copy code
val authorizationPlugin = createRouteScopedPlugin(
    name = "AuthorizationPlugin",
    createConfiguration = ::PluginConfiguration
) {}

class PluginConfiguration {
    var roles: Set<String> = emptySet()
}

fun Application.routing() {
    routing {
        route("user") {
            install(authorizationPlugin) {
                roles = setOf("customer")
            }
            post {
                // customer can create a user
            }

            install(authorizationPlugin) {
                roles = setOf("admin")
            }
            delete {
                // admin can delete a user
            }
        }
    }
}
👌 1
a
What problem do you experience when installing the plugin for different methods?
c
I believe the library doesn't support this, you can only install a plugin on a route and not on individual methods on the route
Is there an example of this?
a
You can use the following code to install a plugin into a method route:
Copy code
method(<http://HttpMethod.Post|HttpMethod.Post>) {
    install(plugin)
    handle {
        call.respondText { "OK" }
    }
}
c
That's a nice and clean solution, we could add this in the documentation if we don't have it already