Documentation
¶
Index ¶
- Variables
- func DoWriteResponse(w http.ResponseWriter, header http.Header, cookies []*http.Cookie, status int, ...)
- func GetExterIp() (string, error)
- func GetInterIp() (string, error)
- func GetListenAddr(a string) (string, error)
- func GetServAddr(a net.Addr) (string, error)
- func HttpRangeDownload(geturl, fileName string, splitSize int, timeout time.Duration) (int, error)
- func HttpReq(url, method string, data []byte, timeout time.Duration) ([]byte, int, error)
- func HttpReqGetOk(url string, timeout time.Duration) ([]byte, error)
- func HttpReqOk(url, method string, data []byte, timeout time.Duration) ([]byte, error)
- func HttpReqPost(url string, data []byte, timeout time.Duration) ([]byte, int, error)
- func HttpReqPostOk(url string, data []byte, timeout time.Duration) ([]byte, error)
- func HttpReqWithHead(url, method string, heads map[string]string, data []byte, ...) ([]byte, int, error)
- func HttpReqWithHeadOk(url, method string, heads map[string]string, data []byte, ...) ([]byte, error)
- func HttpRequestJsonBodyWrapper(fac FactoryHandleRequest) func(http.ResponseWriter, *http.Request, httprouter.Params)
- func HttpRequestWrapper(fac FactoryHandleRequest) func(http.ResponseWriter, *http.Request, httprouter.Params)
- func IpAddrFromRemoteAddr(s string) string
- func IpAddrPort(s string) string
- func IpAddressHttpClient(r *http.Request) string
- func IpBetween(from, to, test net.IP) (bool, error)
- func IpBetweenStr(from, to, test string) (bool, error)
- func IsInterIp(ip string) (bool, error)
- func NewreqArgs(r keyGet) *reqArgs
- func PackageSplit(conn net.Conn, readtimeout time.Duration, readCall func([]byte)) (bool, []byte, error)
- func Packdata(data []byte) []byte
- func PackdataPad(data []byte, pad byte) []byte
- func UnPackdata(lenmin uint, lenmax uint, packBuff []byte, readCall func([]byte)) ([]byte, error)
- type FactoryHandleRequest
- type HandleRequest
- type HttpRequest
- func (m *HttpRequest) Body() *reqBody
- func (m *HttpRequest) Cookies() *reqArgs
- func (m *HttpRequest) Header() http.Header
- func (m *HttpRequest) Headers() *reqArgs
- func (m *HttpRequest) Method() string
- func (m *HttpRequest) Params() *reqArgs
- func (m *HttpRequest) Query() *reqArgs
- func (m *HttpRequest) RemoteAddr() string
- func (m *HttpRequest) Request() *http.Request
- func (m *HttpRequest) URL() *url.URL
- type HttpRespBytes
- type HttpRespJson
- type HttpRespRedirect
- type HttpRespString
- type HttpResponse
- func NewHttpRespBytes(status int, body []byte) HttpResponse
- func NewHttpRespJson(status int, body interface{}) HttpResponse
- func NewHttpRespJson200(body interface{}) HttpResponse
- func NewHttpRespRedirect(r *HttpRequest, status int, redirectUrl string) HttpResponse
- func NewHttpRespString(status int, body string) HttpResponse
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DoWriteResponse ¶
func GetInterIp ¶
func GetListenAddr ¶
不指定host使用内网host 指定了就使用指定的,不管指定的是0.0.0.0还是内网或者外网
func HttpRangeDownload ¶
func HttpReqPost ¶
func HttpReqPostOk ¶
func HttpReqWithHead ¶
func HttpReqWithHeadOk ¶
func HttpRequestJsonBodyWrapper ¶
func HttpRequestJsonBodyWrapper(fac FactoryHandleRequest) func(http.ResponseWriter, *http.Request, httprouter.Params)
func HttpRequestWrapper ¶
func HttpRequestWrapper(fac FactoryHandleRequest) func(http.ResponseWriter, *http.Request, httprouter.Params)
func IpAddrFromRemoteAddr ¶
Request.RemoteAddress contains port, which we want to remove i.e.: "[::1]:58292" => "[::1]"
func IpAddrPort ¶
func IpBetweenStr ¶
func IsInterIp ¶
10.0.0.0/8:10.0.0.0~10.255.255.255 172.16.0.0/12:172.16.0.0~172.31.255.255 192.168.0.0/16:192.168.0.0~192.168.255.255
func NewreqArgs ¶
func NewreqArgs(r keyGet) *reqArgs
func PackageSplit ¶
func PackdataPad ¶
Types ¶
type FactoryHandleRequest ¶
type FactoryHandleRequest func() HandleRequest
type HandleRequest ¶
type HandleRequest interface {
Handle(*HttpRequest) HttpResponse
}
type HttpRequest ¶
type HttpRequest struct {
// contains filtered or unexported fields
}
============================ 没有body类的请求
func NewHttpRequest ¶
func NewHttpRequest(r *http.Request, ps httprouter.Params) (*HttpRequest, error)
func NewHttpRequestJsonBody ¶
func NewHttpRequestJsonBody(r *http.Request, ps httprouter.Params, js interface{}) (*HttpRequest, error)
func (*HttpRequest) Body ¶
func (m *HttpRequest) Body() *reqBody
func (*HttpRequest) Cookies ¶
func (m *HttpRequest) Cookies() *reqArgs
func (*HttpRequest) Header ¶
func (m *HttpRequest) Header() http.Header
func (*HttpRequest) Headers ¶
func (m *HttpRequest) Headers() *reqArgs
func (*HttpRequest) Method ¶
func (m *HttpRequest) Method() string
func (*HttpRequest) Params ¶
func (m *HttpRequest) Params() *reqArgs
func (*HttpRequest) Query ¶
func (m *HttpRequest) Query() *reqArgs
func (*HttpRequest) RemoteAddr ¶
func (m *HttpRequest) RemoteAddr() string
func (*HttpRequest) Request ¶
func (m *HttpRequest) Request() *http.Request
func (*HttpRequest) URL ¶
func (m *HttpRequest) URL() *url.URL
type HttpRespBytes ¶
byte 形式的response
func (*HttpRespBytes) WriteResponse ¶
func (m *HttpRespBytes) WriteResponse(w http.ResponseWriter)
type HttpRespJson ¶
json形式的response
func (*HttpRespJson) WriteResponse ¶
func (m *HttpRespJson) WriteResponse(w http.ResponseWriter)
type HttpRespRedirect ¶
type HttpRespRedirect struct { Status int Url string R *HttpRequest }
redirect
func (*HttpRespRedirect) WriteResponse ¶
func (m *HttpRespRedirect) WriteResponse(w http.ResponseWriter)
type HttpRespString ¶
string 形式的response
func (*HttpRespString) WriteResponse ¶
func (m *HttpRespString) WriteResponse(w http.ResponseWriter)
type HttpResponse ¶
type HttpResponse interface {
WriteResponse(http.ResponseWriter)
}
http response interface
func NewHttpRespBytes ¶
func NewHttpRespBytes(status int, body []byte) HttpResponse
func NewHttpRespJson ¶
func NewHttpRespJson(status int, body interface{}) HttpResponse
func NewHttpRespJson200 ¶
func NewHttpRespJson200(body interface{}) HttpResponse
func NewHttpRespRedirect ¶
func NewHttpRespRedirect(r *HttpRequest, status int, redirectUrl string) HttpResponse
func NewHttpRespString ¶
func NewHttpRespString(status int, body string) HttpResponse
Click to show internal directories.
Click to hide internal directories.