Clarence
08/07/2024, 3:55 AMRouteScopedPlugin
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
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
}
}
}
}
Aleksei Tirman [JB]
08/07/2024, 8:10 AMClarence
08/07/2024, 8:10 AMClarence
08/07/2024, 8:11 AMAleksei Tirman [JB]
08/07/2024, 8:15 AMmethod(<http://HttpMethod.Post|HttpMethod.Post>) {
install(plugin)
handle {
call.respondText { "OK" }
}
}
Clarence
08/07/2024, 11:08 AM