mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
完善ghttp客户端示例
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
package demo
|
||||
|
||||
import (
|
||||
"gitee.com/johng/gf/g/os/glog"
|
||||
"fmt"
|
||||
"gitee.com/johng/gf/g/os/gfile"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Upload(r *ghttp.Request) {
|
||||
@ -16,7 +15,7 @@ func Upload(r *ghttp.Request) {
|
||||
gfile.PutBinContents("/tmp/" + fname, buffer)
|
||||
r.Response.WriteString(fmt.Sprintf("%s upload success, input value:%s", fname, r.GetPostString("name")))
|
||||
} else {
|
||||
glog.Error(e)
|
||||
r.Response.WriteString(e.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,13 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
"gitee.com/johng/gf/g/os/glog"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
path := "/home/john/Workspace/Go/GOPATH/src/gitee.com/johng/gf/version.go"
|
||||
r, e := ghttp.Post("http://127.0.0.1:8199/upload?page=1", "name=john&upload-file=@file:" + path)
|
||||
path := "/home/john/Workspace/Go/gitee.com/johng/gf/version.go"
|
||||
r, e := ghttp.Post("http://127.0.0.1:8199/upload", "name=john&age=18&upload-file=@file:" + path)
|
||||
if e != nil {
|
||||
glog.Error(e)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user