golang lightweight and practical http.Request parameter parsing library paramParse

git Address: https://github.com/LeeDF/paramParse

Http.Request focus for analytical parameters, and return an error

Currently supports commonly used data types, new types can be added

Usage is very simple
welcome Tucao

 

example:

func Hello(w http.ResponseWriter, r *http.Request)  {
	where (
		paramInt64 int64
		paramInt32 int32
		paramStr string
	)

	P := paramParse.NewParseRequest(r)
	Into the reference @: When a pointer variable, a form key, the default value, the default value is nil, equivalent required

	P.Int64Val(&paramInt64, "paramInt64", nil)
	P.Int32Val(&paramInt32, "paramInt32", "0")
	P.Str32Val(&paramStr, "paramInt32", nil)
	if ok := P.DoParse(); !ok {
		fmt.Printf("error parse form fail :%s", P.Err.Error())
		return
	}
}

  

 

Guess you like

Origin www.cnblogs.com/leescre/p/12322757.html