private HttpResponse handleCorsPreflight ( ServiceRequestContext ctx , HttpRequest req ) { final HttpHeaders headers = HttpHeaders . of ( HttpStatus . OK ) ; final CorsPolicy policy = setCorsOrigin ( ctx , req , headers ) ; if ( policy != null ) { policy . setCorsAllowMethods ( headers ) ; policy . setCorsAllowHeaders ( headers ) ; policy . setCorsAllowCredentials ( headers ) ; policy . setCorsMaxAge ( headers ) ; policy . setCorsPreflightResponseHeaders ( headers ) ; } return HttpResponse . of ( headers ) ; }
Handles CORS preflight by setting the appropriate headers .