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
Aleksei Tirman [JB]
08/07/2024, 8:10 AM
What problem do you experience when installing the plugin for different methods?
c
Clarence
08/07/2024, 8:10 AM
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
Clarence
08/07/2024, 8:11 AM
Is there an example of this?
a
Aleksei Tirman [JB]
08/07/2024, 8:15 AM
You can use the following code to install a plugin into a method route: