(next http.Handler)
| 90 | } |
| 91 | |
| 92 | func APIVersionCheckMiddleware(next http.Handler) http.Handler { |
| 93 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 94 | if r.URL.Path == "/info" { |
| 95 | next.ServeHTTP(w, r) |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | clientVersion := r.Header.Get("CortexAPIVersion") |
| 100 | if clientVersion == "" { |
| 101 | respondError(w, r, ErrorHeaderMissing("CortexAPIVersion")) |
| 102 | return |
| 103 | } |
| 104 | |
| 105 | if clientVersion != consts.CortexVersion { |
| 106 | respondError(w, r, ErrorAPIVersionMismatch(consts.CortexVersion, clientVersion)) |
| 107 | return |
| 108 | } |
| 109 | next.ServeHTTP(w, r) |
| 110 | }) |
| 111 | } |
nothing calls this directly
no test coverage detected