This commit is contained in:
aozhiwei 2020-10-28 16:25:29 +08:00
parent 7442ad5d81
commit 933ed5c972

View File

@ -5,6 +5,7 @@ import (
"net"
"net/http"
"time"
"io/ioutil"
"reflect"
)
@ -36,14 +37,20 @@ func Request(r *http.Request, name string) *XValue {
if r.Form == nil {
r.ParseForm()
}
v := &XValue{}
if vs, ok := r.Form[name]; ok {
if len(vs) > 0 {
v.SetString(vs[0])
} else {
v.SetString("")
return NewXString(vs[0])
}
}
return NewXString("")
}
func GetPostBody(r *http.Request) *XValue {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
return NewXString("")
}
v := NewXString(string(body))
return v
}