Commit 27831965 by Torkel Ödegaard

updated

parent e84f06b5
No preview for this file type
...@@ -44,6 +44,7 @@ func Logger() macaron.Handler { ...@@ -44,6 +44,7 @@ func Logger() macaron.Handler {
switch rw.Status() { switch rw.Status() {
case 200: case 200:
content = fmt.Sprintf("\033[1;32m%s\033[0m", content) content = fmt.Sprintf("\033[1;32m%s\033[0m", content)
return
case 304: case 304:
return return
content = fmt.Sprintf("\033[1;33m%s\033[0m", content) content = fmt.Sprintf("\033[1;33m%s\033[0m", content)
......
package api package api
import ( import (
"net/http"
"strconv" "strconv"
"github.com/torkelo/grafana-pro/pkg/components/renderer" "github.com/torkelo/grafana-pro/pkg/components/renderer"
...@@ -14,17 +15,18 @@ func RenderToPng(c *middleware.Context) { ...@@ -14,17 +15,18 @@ func RenderToPng(c *middleware.Context) {
queryParams := "?render&accountId=" + strconv.Itoa(accountId) + "&" + c.Req.URL.RawQuery queryParams := "?render&accountId=" + strconv.Itoa(accountId) + "&" + c.Req.URL.RawQuery
renderOpts := &renderer.RenderOpts{ renderOpts := &renderer.RenderOpts{
Url: c.Params("url") + queryParams, Url: c.Params("*") + queryParams,
Width: queryReader.Get("width", "800"), Width: queryReader.Get("width", "800"),
Height: queryReader.Get("height", "400"), Height: queryReader.Get("height", "400"),
} }
renderOpts.Url = "http://localhost:3000" + renderOpts.Url renderOpts.Url = "http://localhost:3000/" + renderOpts.Url
pngPath, err := renderer.RenderToPng(renderOpts) pngPath, err := renderer.RenderToPng(renderOpts)
if err != nil { if err != nil {
c.HTML(500, "error.html", 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) { ...@@ -27,7 +27,7 @@ func Register(m *macaron.Macaron) {
m.Delete("/api/dashboard/:slug", auth, api.DeleteDashboard) m.Delete("/api/dashboard/:slug", auth, api.DeleteDashboard)
// rendering // rendering
m.Get("/render/*url", auth, api.RenderToPng) m.Get("/render/*", auth, api.RenderToPng)
} }
func Index(ctx *middleware.Context) { 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