add encoding param

This commit is contained in:
jomenxiao 2017-12-11 16:01:17 +08:00
parent 0506cfdc1d
commit ad2a69bff4
2 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,7 @@ func RenderToPng(c *middleware.Context) {
OrgId: c.OrgId,
Timeout: queryReader.Get("timeout", "60"),
Timezone: queryReader.Get("tz", ""),
Encoding: queryReader.Get("encoding", ""),
}
pngPath, err := renderer.RenderToPng(renderOpts)

View File

@ -27,6 +27,7 @@ type RenderOpts struct {
Timeout string
OrgId int64
Timezone string
Encoding string
}
var ErrTimeout = errors.New("Timeout error. You can set timeout in seconds with &timeout url parameter")
@ -95,6 +96,10 @@ func RenderToPng(params *RenderOpts) (string, error) {
"renderKey=" + renderKey,
}
if params.Encoding != "" {
cmdArgs = append([]string{fmt.Sprintf("--output-encoding=%s", params.Encoding)}, cmdArgs...)
}
cmd := exec.Command(binPath, cmdArgs...)
stdout, err := cmd.StdoutPipe()