feat(context): add BindQuery func (#1029)

* feat(context): add BindQuery func, only parse/bind the query string params.

* docs(readme): add BindQuery section.

* docs(readme): fix import.

* docs(readme): separate import
This commit is contained in:
Eason Lin
2017-07-19 15:50:05 +08:00
committed by Javier Provecho Fernandez
parent 74221b8a35
commit c19aa0598b
6 changed files with 109 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package binding
import (
"net/http"
)
type queryBinding struct{}
func (queryBinding) Name() string {
return "query"
}
func (queryBinding) Bind(req *http.Request, obj interface{}) error {
values := req.URL.Query()
if err := mapForm(obj, values); err != nil {
return err
}
return validate(obj)
}