In my armeria project (with spring for DI), i want to apply my decorator to specific services only.
@Component
class MyDecorator(
@Autowired
private val myRepository: Repository,
): DecoratingHttpServiceFunction {
override fun serve(delegate: HttpService, ctx: ServiceRequestContext, req: HttpRequest): HttpResponse {
//.. do something like authorization
return delegate.serve(ctx, req)
}
}
@ProducesJson
@Controller
// @PathPrefix("/a") no path prefix
class ARouter {
@Get("/abc")
fun sample(): String {
return "A"
}
}
@ProducesJson
@Controller
class BRouter {
@Get("/bcd")
fun sample(): String {
return "B"
}
}
@Configuration
class Config {
@Bean
fun armeriaConfig(
//..
): ArmeriaServerConfigurator {
return ArmeriaServerConfigurator { serverBuilder ->
serverBuilder
.decoratorUnder("/", myDecorator)
// .decoratorUnder("/a", myDecorator) no path prefix
The above code applies myDecorator to all routers. Is there any way to allow MyDecorator to be applied only to ARouter? (There is no path prefix for each router.)