(next http.HandlerFunc)
| 82 | } |
| 83 | |
| 84 | func corsMiddleware(next http.HandlerFunc) http.HandlerFunc { |
| 85 | return func(w http.ResponseWriter, r *http.Request) { |
| 86 | if *enableCORS { |
| 87 | w.Header().Set("Access-Control-Allow-Origin", "*") |
| 88 | w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS") |
| 89 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") |
| 90 | } |
| 91 | |
| 92 | if r.Method == "OPTIONS" { |
| 93 | w.WriteHeader(http.StatusOK) |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | next(w, r) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func logMiddleware(next http.HandlerFunc) http.HandlerFunc { |
| 102 | return func(w http.ResponseWriter, r *http.Request) { |
no test coverage detected