@@ -207,25 +207,39 @@ func NewQuerierHandler(
207207 middlewares := middleware .Merge (inst , cacheGenHeaderMiddleware )
208208 router .Use (middlewares .Wrap )
209209
210- promRouter := route .New ().WithPrefix (cfg .ServerPrefix + cfg .PrometheusHTTPPrefix + "/api/v1" )
210+ // Define the prefixes for all routes
211+ prefix := cfg .ServerPrefix + cfg .PrometheusHTTPPrefix
212+ legacyPrefix := cfg .ServerPrefix + cfg .LegacyHTTPPrefix
213+
214+ promRouter := route .New ().WithPrefix (prefix + "/api/v1" )
211215 api .Register (promRouter )
212216
213- legacyPromRouter := route .New ().WithPrefix (cfg . ServerPrefix + cfg . LegacyHTTPPrefix + "/api/v1" )
217+ legacyPromRouter := route .New ().WithPrefix (legacyPrefix + "/api/v1" )
214218 api .Register (legacyPromRouter )
215219
216- //TODO(gotjosh): This custom handler is temporary until we're able to vendor the changes in:
220+ // TODO(gotjosh): This custom handler is temporary until we're able to vendor the changes in:
217221 // https://github.com/prometheus/prometheus/pull/7125/files
218- router .Path (cfg .PrometheusHTTPPrefix + "/api/v1/metadata" ).Handler (querier .MetadataHandler (distributor ))
219- router .Path (cfg .PrometheusHTTPPrefix + "/api/v1/read" ).Handler (querier .RemoteReadHandler (queryable ))
220- // A prefix is fine because external routes will be registered explicitly
221- router .PathPrefix (cfg .PrometheusHTTPPrefix + "/api/v1/" ).Handler (promRouter )
222-
223- //TODO(gotjosh): This custom handler is temporary until we're able to vendor the changes in:
222+ router .Path (prefix + "/api/v1/metadata" ).Handler (querier .MetadataHandler (distributor ))
223+ router .Path (prefix + "/api/v1/read" ).Handler (querier .RemoteReadHandler (queryable ))
224+ router .Path (prefix + "/api/v1/read" ).Methods ("POST" ).Handler (promRouter )
225+ router .Path (prefix + "/api/v1/query" ).Methods ("GET" , "POST" ).Handler (promRouter )
226+ router .Path (prefix + "/api/v1/query_range" ).Methods ("GET" , "POST" ).Handler (promRouter )
227+ router .Path (prefix + "/api/v1/labels" ).Methods ("GET" , "POST" ).Handler (promRouter )
228+ router .Path (prefix + "/api/v1/label/{name}/values" ).Methods ("GET" ).Handler (promRouter )
229+ router .Path (prefix + "/api/v1/series" ).Methods ("GET" , "POST" , "DELETE" ).Handler (promRouter )
230+ router .Path (prefix + "/api/v1/metadata" ).Methods ("GET" ).Handler (promRouter )
231+
232+ // TODO(gotjosh): This custom handler is temporary until we're able to vendor the changes in:
224233 // https://github.com/prometheus/prometheus/pull/7125/files
225- router .Path (cfg .LegacyHTTPPrefix + "/api/v1/metadata" ).Handler (querier .MetadataHandler (distributor ))
226- router .Path (cfg .LegacyHTTPPrefix + "/api/v1/read" ).Handler (querier .RemoteReadHandler (queryable ))
227- // A prefix is fine because external routes will be registered explicitly
228- router .PathPrefix (cfg .LegacyHTTPPrefix + "/api/v1/" ).Handler (legacyPromRouter )
234+ router .Path (legacyPrefix + "/api/v1/metadata" ).Handler (querier .MetadataHandler (distributor ))
235+ router .Path (legacyPrefix + "/api/v1/read" ).Handler (querier .RemoteReadHandler (queryable ))
236+ router .Path (legacyPrefix + "/api/v1/read" ).Methods ("POST" ).Handler (legacyPromRouter )
237+ router .Path (legacyPrefix + "/api/v1/query" ).Methods ("GET" , "POST" ).Handler (legacyPromRouter )
238+ router .Path (legacyPrefix + "/api/v1/query_range" ).Methods ("GET" , "POST" ).Handler (legacyPromRouter )
239+ router .Path (legacyPrefix + "/api/v1/labels" ).Methods ("GET" , "POST" ).Handler (legacyPromRouter )
240+ router .Path (legacyPrefix + "/api/v1/label/{name}/values" ).Methods ("GET" ).Handler (legacyPromRouter )
241+ router .Path (legacyPrefix + "/api/v1/series" ).Methods ("GET" , "POST" , "DELETE" ).Handler (legacyPromRouter )
242+ router .Path (legacyPrefix + "/api/v1/metadata" ).Methods ("GET" ).Handler (legacyPromRouter )
229243
230244 // Add a middleware to extract the trace context and add a header.
231245 return nethttp .MiddlewareFunc (opentracing .GlobalTracer (), router .ServeHTTP , nethttp .OperationNameFunc (func (r * http.Request ) string {
0 commit comments