mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Set correct Content-Type header based on output format.
This commit is contained in:
parent
84dd62fb9b
commit
ab746d068e
|
@ -1,6 +1,7 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.google.com/p/gorest"
|
||||||
"github.com/matttproud/prometheus/rules"
|
"github.com/matttproud/prometheus/rules"
|
||||||
"github.com/matttproud/prometheus/rules/ast"
|
"github.com/matttproud/prometheus/rules/ast"
|
||||||
"time"
|
"time"
|
||||||
|
@ -13,9 +14,15 @@ func (serv MetricsService) Query(Expr string, Json string, Start string, End str
|
||||||
|
|
||||||
timestamp := time.Now()
|
timestamp := time.Now()
|
||||||
|
|
||||||
format := ast.TEXT
|
rb := serv.ResponseBuilder()
|
||||||
|
var format ast.OutputFormat
|
||||||
if Json != "" {
|
if Json != "" {
|
||||||
format = ast.JSON
|
format = ast.JSON
|
||||||
|
rb.SetContentType(gorest.Application_Json)
|
||||||
|
} else {
|
||||||
|
format = ast.TEXT
|
||||||
|
rb.SetContentType(gorest.Text_Plain)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ast.EvalToString(exprNode, ×tamp, format)
|
return ast.EvalToString(exprNode, ×tamp, format)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue