preflightHandler adds the necessary headers in order to serve CORS from any origin using the methods "GET", "HEAD", "POST", "PUT", "DELETE" We insist, don't do this without consideration in production systems.
(w http.ResponseWriter, r *http.Request)
| 49 | // CORS from any origin using the methods "GET", "HEAD", "POST", "PUT", "DELETE" |
| 50 | // We insist, don't do this without consideration in production systems. |
| 51 | func preflightHandler(w http.ResponseWriter, r *http.Request) { |
| 52 | headers := []string{"Content-Type", "Accept", "Authorization"} |
| 53 | w.Header().Set("Access-Control-Allow-Headers", strings.Join(headers, ",")) |
| 54 | methods := []string{"GET", "HEAD", "POST", "PUT", "DELETE"} |
| 55 | w.Header().Set("Access-Control-Allow-Methods", strings.Join(methods, ",")) |
| 56 | grpclog.Infof("Preflight request for %s", r.URL.Path) |
| 57 | } |
| 58 | |
| 59 | // healthzServer returns a simple health handler which returns ok. |
| 60 | func healthzServer(conn *grpc.ClientConn) http.HandlerFunc { |