Documentation
¶
Index ¶
- Constants
- type Context
- type File_Info
- type Form
- type Method
- type WebBenchmark
- type WebClient
- func (me *WebClient) DownloadFile(relativePath string, savePath string, params Form, handles ...responseHandle) error
- func (me *WebClient) Form_DELETE(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
- func (me *WebClient) Form_GET(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
- func (me *WebClient) Form_POST(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
- func (me *WebClient) Form_PUT(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
- func (me *WebClient) Form_request(method Method, relativePath string, params Form, handles ...responseHandle) ([]byte, error)
- func (me *WebClient) GetCookies(rawURL string) ([]*http.Cookie, error)
- func (me *WebClient) HTTP_request(method Method, relativePath string, contentType string, params io.Reader, ...) (*http.Response, error)
- func (me *WebClient) JSON_DELETE(relativePath string, params interface{}, response interface{}, ...) error
- func (me *WebClient) JSON_GET(relativePath string, params interface{}, response interface{}, ...) error
- func (me *WebClient) JSON_POST(relativePath string, params interface{}, response interface{}, ...) error
- func (me *WebClient) JSON_PUT(relativePath string, params interface{}, response interface{}, ...) error
- func (me *WebClient) JSON_request(method Method, relativePath string, params interface{}, response interface{}, ...) error
- func (me *WebClient) SetCookie(rawURL string, name string, value string) error
- func (me *WebClient) SetCookies(rawURL string, cookies []*http.Cookie) error
- func (me *WebClient) SetHeader(key string, value string)
- func (me *WebClient) UploadFile(relativePath string, field string, path string, params Form, ...) ([]byte, error)
- type WebServer
- func (me *WebServer) HandleDELETE(relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandleFunc(method Method, relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandleGET(relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandleOPTIONS(relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandlePATCH(relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandlePOST(relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandlePUT(relativePath string, handle func(Context)) *WebServer
- func (me *WebServer) HandleStruct(relativePath string, handle interface{}) *WebServer
- func (me *WebServer) Run() error
Constants ¶
View Source
const ( ContentType_Form = "application/x-www-form-urlencoded" ContentType_JSON = "application/json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Method ¶
type Method string
Method http方法类型
const DELETE Method = "DELETE"
const GET Method = "GET"
const OPTIONS Method = "OPTIONS"
const PATCH Method = "PATCH"
const POST Method = "POST"
const PUT Method = "PUT"
type WebBenchmark ¶
type WebBenchmark struct {
// contains filtered or unexported fields
}
WebBenchmark 基准测试类型
func (*WebBenchmark) RunSingleAPI ¶
func (me *WebBenchmark) RunSingleAPI(tps int, rounds int, interval time.Duration, req func(*WebClient, int) error) benchmark.BenchmarkCount
Run single API 单个API基准测试
type WebClient ¶
type WebClient struct {
// contains filtered or unexported fields
}
WebClient web请求辅助工具
func (*WebClient) DownloadFile ¶
func (me *WebClient) DownloadFile(relativePath string, savePath string, params Form, handles ...responseHandle) error
DownloadFile 文件下载方法
func (*WebClient) Form_DELETE ¶
func (me *WebClient) Form_DELETE(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
Form_DELETE 表单delete
func (*WebClient) Form_GET ¶
func (me *WebClient) Form_GET(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
Form_GET 表单get
func (*WebClient) Form_POST ¶
func (me *WebClient) Form_POST(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
Form_POST 表单post
func (*WebClient) Form_PUT ¶
func (me *WebClient) Form_PUT(relativePath string, params Form, handles ...responseHandle) ([]byte, error)
Form_PUT 表单put
func (*WebClient) Form_request ¶
func (me *WebClient) Form_request(method Method, relativePath string, params Form, handles ...responseHandle) ([]byte, error)
Form_request 表单请求
func (*WebClient) GetCookies ¶
GetCookies 根据域名获取cookies
func (*WebClient) HTTP_request ¶
func (me *WebClient) HTTP_request(method Method, relativePath string, contentType string, params io.Reader, header map[string]interface{}) (*http.Response, error)
HTTP_request http请求
func (*WebClient) JSON_DELETE ¶
func (me *WebClient) JSON_DELETE(relativePath string, params interface{}, response interface{}, handles ...responseHandle) error
JSON_DELETE JSON delete
func (*WebClient) JSON_GET ¶
func (me *WebClient) JSON_GET(relativePath string, params interface{}, response interface{}, handles ...responseHandle) error
JSON_GET JSON get
func (*WebClient) JSON_POST ¶
func (me *WebClient) JSON_POST(relativePath string, params interface{}, response interface{}, handles ...responseHandle) error
JSON_POST JSON post
func (*WebClient) JSON_PUT ¶
func (me *WebClient) JSON_PUT(relativePath string, params interface{}, response interface{}, handles ...responseHandle) error
JSON_PUT JSON put
func (*WebClient) JSON_request ¶
func (me *WebClient) JSON_request(method Method, relativePath string, params interface{}, response interface{}, handles ...responseHandle) error
JSON_request JSON请求
func (*WebClient) SetCookies ¶
SetCookies 根据域名设置cookies
type WebServer ¶
type WebServer struct {
// contains filtered or unexported fields
}
WebServer web服务辅助工具
func NewWebServerDefault ¶
NewWebServerDefault 构建web服务数据对象,domain可以为空
func (*WebServer) HandleDELETE ¶
HandleDELETE 监听Delete
func (*WebServer) HandleFunc ¶
func (me *WebServer) HandleFunc(method Method, relativePath string, handle func(Context)) *WebServer
Handle_Func 监听函数
func (*WebServer) HandleOPTIONS ¶
HandleOPTIONS 监听Options
func (*WebServer) HandlePATCH ¶
HandlePATCH 监听Patch
func (*WebServer) HandlePOST ¶
HandlePOST 监听Post
func (*WebServer) HandleStruct ¶
HandleStruct 监听结构体,反射街头的http方法以及遍历每个字段的http方法,实现REST形式的API服务 结构体的方法必须与 Method 类型的名称一致
Click to show internal directories.
Click to hide internal directories.