MCPcopy
hub / github.com/cortexlabs/cortex / APIVersionCheckMiddleware

Function APIVersionCheckMiddleware

pkg/operator/endpoints/middleware.go:92–111  ·  view source on GitHub ↗
(next http.Handler)

Source from the content-addressed store, hash-verified

90}
91
92func 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}

Callers

nothing calls this directly

Calls 4

respondErrorFunction · 0.85
ErrorHeaderMissingFunction · 0.85
ErrorAPIVersionMismatchFunction · 0.85
ServeHTTPMethod · 0.45

Tested by

no test coverage detected