Set correct Content-Type header based on output format.

This commit is contained in:
Julius Volz 2013-01-11 03:17:58 +01:00
parent 84dd62fb9b
commit ab746d068e
1 changed files with 8 additions and 1 deletions

View File

@ -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, &timestamp, format)
}