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