private HttpResponse handleCorsPreflight(ServiceRequestContext ctx, HttpRequest req) {
        final ResponseHeadersBuilder headers = ResponseHeaders.builder(HttpStatus.OK);

        final CorsPolicy policy = CorsHeaderUtil.setCorsOrigin(ctx, req, headers, config);
        if (policy != null) {
            policy.setCorsAllowMethods(headers);
            final RequestHeaders requestHeaders = req.headers();
            CorsHeaderUtil.setCorsAllowHeaders(requestHeaders, headers, policy);
            CorsHeaderUtil.setCorsAllowCredentials(headers, policy);
            policy.setCorsMaxAge(headers);
            policy.setCorsPreflightResponseHeaders(headers);
        }

        return HttpResponse.of(headers.build());
    }
Handles CORS preflight by setting the appropriate headers.

@param req the decoded HTTP request
core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java