@Override
    public Function<? super HttpService, ? extends HttpService> newDecorator(CorsDecorators parameter) {
        ensureValidConfig(parameter);
        final CorsDecorator[] policies = parameter.value();
        final CorsDecorator corsDecorator = policies[0];
        final CorsServiceBuilder cb = CorsService.builder(corsDecorator.origins());
        if (parameter.shortCircuit()) {
            cb.shortCircuit();
        }
        cb.firstPolicyBuilder.setConfig(corsDecorator);
        for (int i = 1; i < policies.length; i++) {
            final CorsPolicyBuilder builder = CorsPolicy.builder(policies[i].origins());
            builder.setConfig(policies[i]);
            cb.addPolicy(builder.build());
        }

        final Function<? super HttpService, CorsService> decorator = cb.newDecorator();
        return service -> {
            if (service.as(CorsService.class) != null) {
                return service;
            } else {
                return decorator.apply(service);
            }
        };
    }
A factory which creates a {@link CorsService} decorator when two or more {@link CorsDecorator}s are added.
core/src/main/java/com/linecorp/armeria/server/cors/CorsDecoratorsFactoryFunction.java