class CorsHandler implements HttpHandler, HandlerWrapper {

  void handlePreflight(HttpServerExchange exchange) {
    HeaderMap requestHeaders = exchange.getRequestHeaders();
    String origin = requestHeaders.getFirst(ORIGIN);
    String method = requestHeaders.getFirst(ACCESS_CONTROL_REQUEST_METHOD);
    String requestedHeaders = requestHeaders.getFirst(ACCESS_CONTROL_REQUEST_HEADERS);
    HeaderMap responseHeaders = exchange.getResponseHeaders();

    responseHeaders.put(VARY,
      "origin,access-control-request-method,access-control-request-headers");
    if (
      ("POST".equals(method) || "GET".equals(method))
        && requestedHeadersAllowed(requestedHeaders)
        && setOrigin(origin, responseHeaders)
      ) {
      responseHeaders.put(ACCESS_CONTROL_ALLOW_METHODS, method);
      if (requestedHeaders != null) {
        responseHeaders.put(ACCESS_CONTROL_ALLOW_HEADERS, requestedHeaders);
      }
    }
  }

    CorsHandler(String allowedOrigins);

}