Documentation
¶
Index ¶
- func CompTime(t1, t2 int64) int64
- func ConnPath(args ...string) string
- func Response(conn net.Conn, code int, codeCommand string, data []byte, contextType string) error
- func Str2int64(str string) int64
- type Handler
- type HttpClient
- func (me *HttpClient) Download(uri string, fh *os.File) (int64, error)
- func (me *HttpClient) Get(uri string) ([]byte, error)
- func (me *HttpClient) GetBody() []byte
- func (me *HttpClient) GetHeader(name string) string
- func (me *HttpClient) GetHeaders() map[string][]string
- func (me *HttpClient) GetStatusCode() int
- func (me *HttpClient) GetTimeout(uri string, second int) ([]byte, error)
- func (me *HttpClient) Post(uri string, data []byte) ([]byte, error)
- func (me *HttpClient) Put(uri string, data []byte) ([]byte, error)
- func (me *HttpClient) SetCert(ca string, cert, key string, auth bool)
- func (me *HttpClient) SetConnTimeout(ms int)
- func (me *HttpClient) SetHttpHeader(name string, value string)
- func (me *HttpClient) SetProxy(proxy string)
- func (me *HttpClient) SetTimeout(v int)
- func (me *HttpClient) SetTotalTimeout(ms int)
- func (me *HttpClient) SetUserAgent(agent string)
- type HttpInstance
- type HttpRequest
- func (me *HttpRequest) Form(name string) (string, bool)
- func (me *HttpRequest) GetBody() []byte
- func (me *HttpRequest) GetHeader(name string) string
- func (me *HttpRequest) GetHeaders() url.Values
- func (me *HttpRequest) GetStatus() HttpStatus
- func (me *HttpRequest) LocalIP() string
- func (me *HttpRequest) Method() string
- func (me *HttpRequest) ParseForm()
- func (me *HttpRequest) RemoteAddr() string
- func (me *HttpRequest) RemoteIP() string
- func (me *HttpRequest) RequestURI() string
- type HttpResponse
- func (me *HttpResponse) DeleteHttpHeader(name string)
- func (me *HttpResponse) GetHeader(name string) string
- func (me *HttpResponse) ResetHttpHeader()
- func (me *HttpResponse) SetHttpHeader(name string, value string)
- func (me *HttpResponse) SetStatusCode(code int)
- func (me *HttpResponse) Write(buf []byte)
- func (me *HttpResponse) WriteString(str string)
- type HttpServer
- type HttpStatus
- type Router
- type RouterMgr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler interface {
ServeHTTP(*HttpResponse, *HttpRequest)
}
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(url string, keepAlive bool) *HttpClient
func (*HttpClient) GetBody ¶
func (me *HttpClient) GetBody() []byte
func (*HttpClient) GetHeader ¶
func (me *HttpClient) GetHeader(name string) string
func (*HttpClient) GetHeaders ¶
func (me *HttpClient) GetHeaders() map[string][]string
func (*HttpClient) GetStatusCode ¶
func (me *HttpClient) GetStatusCode() int
func (*HttpClient) GetTimeout ¶
func (me *HttpClient) GetTimeout(uri string, second int) ([]byte, error)
func (*HttpClient) SetConnTimeout ¶
func (me *HttpClient) SetConnTimeout(ms int)
func (*HttpClient) SetHttpHeader ¶
func (me *HttpClient) SetHttpHeader(name string, value string)
func (*HttpClient) SetProxy ¶
func (me *HttpClient) SetProxy(proxy string)
func (*HttpClient) SetTimeout ¶
func (me *HttpClient) SetTimeout(v int)
func (*HttpClient) SetTotalTimeout ¶
func (me *HttpClient) SetTotalTimeout(ms int)
func (*HttpClient) SetUserAgent ¶
func (me *HttpClient) SetUserAgent(agent string)
type HttpInstance ¶
type HttpInstance struct {
// contains filtered or unexported fields
}
func (*HttpInstance) GetRequestData ¶
func (me *HttpInstance) GetRequestData() []byte
func (*HttpInstance) GetStatus ¶
func (me *HttpInstance) GetStatus() HttpStatus
func (*HttpInstance) Write ¶
func (me *HttpInstance) Write(data []byte)
func (*HttpInstance) WriteString ¶
func (me *HttpInstance) WriteString(str string)
type HttpRequest ¶
type HttpRequest struct {
// contains filtered or unexported fields
}
func (*HttpRequest) GetBody ¶
func (me *HttpRequest) GetBody() []byte
func (*HttpRequest) GetHeader ¶
func (me *HttpRequest) GetHeader(name string) string
func (*HttpRequest) GetHeaders ¶
func (me *HttpRequest) GetHeaders() url.Values
func (*HttpRequest) GetStatus ¶
func (me *HttpRequest) GetStatus() HttpStatus
func (*HttpRequest) LocalIP ¶
func (me *HttpRequest) LocalIP() string
func (*HttpRequest) Method ¶
func (me *HttpRequest) Method() string
func (*HttpRequest) ParseForm ¶
func (me *HttpRequest) ParseForm()
func (*HttpRequest) RemoteAddr ¶
func (me *HttpRequest) RemoteAddr() string
func (*HttpRequest) RemoteIP ¶
func (me *HttpRequest) RemoteIP() string
func (*HttpRequest) RequestURI ¶
func (me *HttpRequest) RequestURI() string
type HttpResponse ¶
type HttpResponse struct {
// contains filtered or unexported fields
}
func (*HttpResponse) DeleteHttpHeader ¶
func (me *HttpResponse) DeleteHttpHeader(name string)
func (*HttpResponse) GetHeader ¶
func (me *HttpResponse) GetHeader(name string) string
func (*HttpResponse) ResetHttpHeader ¶
func (me *HttpResponse) ResetHttpHeader()
func (*HttpResponse) SetHttpHeader ¶
func (me *HttpResponse) SetHttpHeader(name string, value string)
func (*HttpResponse) SetStatusCode ¶
func (me *HttpResponse) SetStatusCode(code int)
func (*HttpResponse) Write ¶
func (me *HttpResponse) Write(buf []byte)
func (*HttpResponse) WriteString ¶
func (me *HttpResponse) WriteString(str string)
type HttpServer ¶
type HttpServer struct {
Router RouterMgr
OnConnect func(inst *HttpInstance, conn *net.TCPConn)
/* bAttach:true 不处理http请求,有调用处理连接 */
OnAccept func(conn net.Conn, bAttach *bool)
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(bind string) *HttpServer
func (*HttpServer) AddBind ¶
func (me *HttpServer) AddBind(name string, bind string)
func (*HttpServer) GetRouter ¶
func (me *HttpServer) GetRouter() *RouterMgr
func (*HttpServer) RelayTCPConnect ¶
func (me *HttpServer) RelayTCPConnect(conn net.Conn, remoteAddr string) error
func (*HttpServer) SetDebug ¶
func (me *HttpServer) SetDebug(debug bool)
func (*HttpServer) Start ¶
func (me *HttpServer) Start() error
func (*HttpServer) Stop ¶
func (me *HttpServer) Stop()
type HttpStatus ¶
type RouterMgr ¶
type RouterMgr struct {
// contains filtered or unexported fields
}
func (*RouterMgr) AddRouter ¶
func (me *RouterMgr) AddRouter(path string, handler interface{}, absPath bool, args ...string) *Router
AddRouter /*
path: uri@name uri: http uri name: server name, optional
handler:
func(*HttpResponse, *HttpRequest) func(*HttpInstance)
func (*RouterMgr) AddRouterFunc ¶
func (me *RouterMgr) AddRouterFunc(path string, handler func(*HttpResponse, *HttpRequest), absPath bool, args ...string) *Router
Click to show internal directories.
Click to hide internal directories.