@Override
    public Function<? super HttpService, ? extends HttpService> newDecorator(CorsDecorator parameter) {
        requireNonNull(parameter, "parameter");
        if (parameter.origins().length == 0 && parameter.originRegexes().length == 0) {
            throw new IllegalArgumentException("Either origins or originRegex must be configured");
        }

        final CorsServiceBuilder cb;
        final List<String> origins = Arrays.asList(parameter.origins());
        if (!origins.isEmpty() && origins.contains("*")) {
            cb = CorsService.builderForAnyOrigin();
        } else {
            Predicate<String> originPredicate;
            if (!origins.isEmpty()) {
                originPredicate = origins::contains;
            } else {
                originPredicate = origin -> false;
            }

            for (String originRegex : parameter.originRegexes()) {
                final Pattern regex = Pattern.compile(originRegex);
                originPredicate = originPredicate.or(regex.asPredicate());
            }

            cb = CorsService.builder(originPredicate);
        }

        cb.firstPolicyBuilder.setConfig(parameter);

        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 only one {@link CorsDecorator} is added.
core/src/main/java/com/linecorp/armeria/server/cors/CorsDecoratorFactoryFunction.java