Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) RequestJson(ctx context.Context, method string, endpoint string, data ...interface{}) *gjson.Json
- func (c *Client) RequestPost(ctx context.Context, endpoint string, data ...interface{}) *gjson.Json
- func (c *Client) RequestRaw(ctx context.Context, method string, endpoint string, data ...interface{}) []byte
- type Request
- type Response
- func (r *Response) ClearBuffer()
- func (r *Response) Output()
- func (r *Response) Write(content ...interface{})
- func (r *Response) WriteStatus(status int, content ...interface{})
- func (r *Response) WriteStatusExit(status int, content ...interface{})
- func (r *Response) WriteXml(content interface{}, rootTag ...string) error
- type ResponseData
- type ResponseWriter
- func (w *ResponseWriter) Flush()
- func (w *ResponseWriter) Header() http.Header
- func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *ResponseWriter) RawWriter() http.ResponseWriter
- func (w *ResponseWriter) Write(data []byte) (int, error)
- func (w *ResponseWriter) WriteHeader(status int)
Constants ¶
const (
EXCEPTION_EXIT = "exit"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Client *gclient.Client
// BeforeRequest gclient.HandlerFunc
// AfterReponse gclient.HandlerFunc
BaseUri string // 请求接口通用前缀
Logger *log.Logger
UrlValues url.Values
}
func (*Client) RequestJson ¶
func (c *Client) RequestJson(ctx context.Context, method string, endpoint string, data ...interface{}) *gjson.Json
request
func (*Client) RequestPost ¶
request post 需要上传文件等用,配合 @file
type Request ¶
Request struct
type Response ¶
type Response struct {
*ResponseWriter
Writer *ResponseWriter
}
Response
func (*Response) ClearBuffer ¶
func (r *Response) ClearBuffer()
ClearBuffer clears the response buffer.
func (*Response) Output ¶
func (r *Response) Output()
Output outputs the buffer content to the client and clears the buffer.
func (*Response) Write ¶
func (r *Response) Write(content ...interface{})
Write writes <content> to the response buffer.
func (*Response) WriteStatus ¶
Note that do not set Content-Type header here.
func (*Response) WriteStatusExit ¶
type ResponseData ¶
ResponseData 针对微信接口返回json格式数据设置,errcode errmsg
func (*ResponseData) HaveError ¶
func (r *ResponseData) HaveError() bool
HaveError Ok 当返回errcode=0, errmsg="ok" 时为false errcode != 0 时为true
type ResponseWriter ¶
type ResponseWriter struct {
Status int // HTTP status.
// contains filtered or unexported fields
}
ResponseWriter is the custom writer for http response.
func (*ResponseWriter) Flush ¶
func (w *ResponseWriter) Flush()
OutputBuffer outputs the buffer to client and clears the buffer.
func (*ResponseWriter) Header ¶
func (w *ResponseWriter) Header() http.Header
Header implements the interface function of http.ResponseWriter.Header.
func (*ResponseWriter) Hijack ¶
func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack implements the interface function of http.Hijacker.Hijack.
func (*ResponseWriter) RawWriter ¶
func (w *ResponseWriter) RawWriter() http.ResponseWriter
RawWriter returns the underlying ResponseWriter.
func (*ResponseWriter) Write ¶
func (w *ResponseWriter) Write(data []byte) (int, error)
Write implements the interface function of http.ResponseWriter.Write.
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(status int)
WriteHeader implements the interface of http.ResponseWriter.WriteHeader.