mirror of
https://github.com/openfaas/faas.git
synced 2025-06-23 15:23:29 +00:00
Refactoring: variable names, adding tests and http constants
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
@ -30,14 +30,16 @@ func NewPrometheusQuery(host string, port int, client *http.Client) PrometheusQu
|
||||
// Fetch queries aggregated stats
|
||||
func (q PrometheusQuery) Fetch(query string) (*VectorQueryResponse, error) {
|
||||
|
||||
req, reqErr := http.NewRequest("GET", fmt.Sprintf("http://%s:%d/api/v1/query/?query=%s", q.Host, q.Port, query), nil)
|
||||
req, reqErr := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s:%d/api/v1/query/?query=%s", q.Host, q.Port, query), nil)
|
||||
if reqErr != nil {
|
||||
return nil, reqErr
|
||||
}
|
||||
|
||||
res, getErr := q.Client.Do(req)
|
||||
if getErr != nil {
|
||||
return nil, getErr
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
bytesOut, readErr := ioutil.ReadAll(res.Body)
|
||||
if readErr != nil {
|
||||
|
Reference in New Issue
Block a user