Commit 89fb60a9 by Carl Bergquist Committed by GitHub

Merge pull request #10020 from jomenxiao/master

fix render http[get] params error
parents 92821828 3f95180c
...@@ -10,7 +10,11 @@ import ( ...@@ -10,7 +10,11 @@ import (
) )
func RenderToPng(c *middleware.Context) { func RenderToPng(c *middleware.Context) {
queryReader := util.NewUrlQueryReader(c.Req.URL) queryReader, err := util.NewUrlQueryReader(c.Req.URL)
if err != nil {
c.Handle(400, "Rander parameters error", err)
return
}
queryParams := fmt.Sprintf("?%s", c.Req.URL.RawQuery) queryParams := fmt.Sprintf("?%s", c.Req.URL.RawQuery)
renderOpts := &renderer.RenderOpts{ renderOpts := &renderer.RenderOpts{
......
...@@ -9,10 +9,15 @@ type UrlQueryReader struct { ...@@ -9,10 +9,15 @@ type UrlQueryReader struct {
values url.Values values url.Values
} }
func NewUrlQueryReader(url *url.URL) *UrlQueryReader { func NewUrlQueryReader(urlInfo *url.URL) (*UrlQueryReader, error) {
return &UrlQueryReader{ u, err := url.ParseQuery(urlInfo.String())
values: url.Query(), if err != nil {
return nil, err
} }
return &UrlQueryReader{
values: u,
}, nil
} }
func (r *UrlQueryReader) Get(name string, def string) string { func (r *UrlQueryReader) Get(name string, def string) string {
......
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