Преглед изворни кода

Use the Warning Get/Set for Request Context in util

Matt Bolt пре 5 година
родитељ
комит
4abd160371
2 измењених фајлова са 1 додато и 11 уклоњено
  1. 1 1
      pkg/costmodel/aggregation.go
  2. 0 10
      pkg/costmodel/router.go

+ 1 - 1
pkg/costmodel/aggregation.go

@@ -1784,7 +1784,7 @@ func (a *Accesses) AggregateCostModelHandler(w http.ResponseWriter, r *http.Requ
 	data, message, err = a.AggAPI.ComputeAggregateCostModel(promClient, duration, offset, field, subfields, rate, filters, sr, shared, allocateIdle, includeTimeSeries, includeEfficiency, disableCache, clearCache, noCache, noExpireCache, remoteEnabled, false, useETLAdapter)
 
 	// Find any warnings in http request context
-	warning, _ := GetWarning(r)
+	warning, _ := util.GetWarning(r)
 
 	if err != nil {
 		if emptyErr, ok := err.(*EmptyDataError); ok {

+ 0 - 10
pkg/costmodel/router.go

@@ -401,16 +401,6 @@ func WrapDataWithMessageAndWarning(data interface{}, err error, message, warning
 	return resp
 }
 
-const (
-	ContextWarning string = "Warning"
-)
-
-// GetWarning Extracts a warning message from the request context if it exists
-func GetWarning(r *http.Request) (warning string, ok bool) {
-	warning, ok = r.Context().Value(ContextWarning).(string)
-	return
-}
-
 // RefreshPricingData needs to be called when a new node joins the fleet, since we cache the relevant subsets of pricing data to avoid storing the whole thing.
 func (a *Accesses) RefreshPricingData(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
 	w.Header().Set("Content-Type", "application/json")