Commit 27831965 by Torkel Ödegaard

updated

parent e84f06b5
No preview for this file type
......@@ -44,6 +44,7 @@ func Logger() macaron.Handler {
switch rw.Status() {
case 200:
content = fmt.Sprintf("\033[1;32m%s\033[0m", content)
return
case 304:
return
content = fmt.Sprintf("\033[1;33m%s\033[0m", content)
......
package api
import (
"net/http"
"strconv"
"github.com/torkelo/grafana-pro/pkg/components/renderer"
......@@ -14,17 +15,18 @@ func RenderToPng(c *middleware.Context) {
queryParams := "?render&accountId=" + strconv.Itoa(accountId) + "&" + c.Req.URL.RawQuery
renderOpts := &renderer.RenderOpts{
Url: c.Params("url") + queryParams,
Url: c.Params("*") + queryParams,
Width: queryReader.Get("width", "800"),
Height: queryReader.Get("height", "400"),
}
renderOpts.Url = "http://localhost:3000" + renderOpts.Url
renderOpts.Url = "http://localhost:3000/" + renderOpts.Url
pngPath, err := renderer.RenderToPng(renderOpts)
if err != nil {
c.HTML(500, "error.html", nil)
}
c.ServeFile(pngPath)
c.Resp.Header().Set("Content-Type", "image/png")
http.ServeFile(c.Resp, c.Req, pngPath)
}
......@@ -27,7 +27,7 @@ func Register(m *macaron.Macaron) {
m.Delete("/api/dashboard/:slug", auth, api.DeleteDashboard)
// rendering
m.Get("/render/*url", auth, api.RenderToPng)
m.Get("/render/*", auth, api.RenderToPng)
}
func Index(ctx *middleware.Context) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment