Commit 3f95180c by jomenxiao

fix render http[get] params error

parent c0e08764
...@@ -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