fix golint issues, else blocks (#457)

This commit is contained in:
Kevin Wan
2021-02-09 13:50:21 +08:00
committed by GitHub
parent 42883d0899
commit 5e969cbef0
66 changed files with 341 additions and 311 deletions

View File

@@ -24,6 +24,7 @@ var (
pathUnmarshaler = mapping.NewUnmarshaler(pathKey, mapping.WithStringValues())
)
// Parse parses the request.
func Parse(r *http.Request, v interface{}) error {
if err := ParsePath(r, v); err != nil {
return err
@@ -36,7 +37,7 @@ func Parse(r *http.Request, v interface{}) error {
return ParseJsonBody(r, v)
}
// Parses the form request.
// ParseForm parses the form request.
func ParseForm(r *http.Request, v interface{}) error {
if err := r.ParseForm(); err != nil {
return err
@@ -80,7 +81,7 @@ func ParseHeader(headerValue string) map[string]string {
return ret
}
// Parses the post request which contains json in body.
// ParseJsonBody parses the post request which contains json in body.
func ParseJsonBody(r *http.Request, v interface{}) error {
var reader io.Reader
if withJsonBody(r) {
@@ -92,7 +93,7 @@ func ParseJsonBody(r *http.Request, v interface{}) error {
return mapping.UnmarshalJsonReader(reader, v)
}
// Parses the symbols reside in url path.
// ParsePath parses the symbols reside in url path.
// Like http://localhost/bag/:name
func ParsePath(r *http.Request, v interface{}) error {
vars := context.Vars(r)

View File

@@ -4,7 +4,7 @@ import "net/http"
const xForwardFor = "X-Forward-For"
// Returns the peer address, supports X-Forward-For
// GetRemoteAddr returns the peer address, supports X-Forward-For.
func GetRemoteAddr(r *http.Request) string {
v := r.Header.Get(xForwardFor)
if len(v) > 0 {