Documentation
¶
Index ¶
- Constants
- Variables
- func Listen(network string, address string, options ...Option) (net.Listener, error)
- type BufConn
- type ClientConn
- func (c *ClientConn) Close() error
- func (c *ClientConn) LocalAddr() net.Addr
- func (c *ClientConn) Read(p []byte) (n int, err error)
- func (c *ClientConn) RemoteAddr() net.Addr
- func (c *ClientConn) SetDeadline(t time.Time) error
- func (c *ClientConn) SetReadDeadline(t time.Time) error
- func (c *ClientConn) SetWriteDeadline(t time.Time) error
- func (c *ClientConn) String() string
- func (c *ClientConn) Write(p []byte) (n int, err error)
- type CommonOptions
- type Dialer
- type Listener
- type Option
- type ServerConn
- func (c *ServerConn) Close() error
- func (c *ServerConn) LocalAddr() net.Addr
- func (c *ServerConn) Read(p []byte) (n int, err error)
- func (c *ServerConn) RemoteAddr() net.Addr
- func (c *ServerConn) SetDeadline(t time.Time) error
- func (c *ServerConn) SetReadDeadline(t time.Time) error
- func (c *ServerConn) SetWriteDeadline(t time.Time) error
- func (c *ServerConn) String() string
- func (c *ServerConn) Write(p []byte) (n int, err error)
- type WSConn
Constants ¶
View Source
const ( PING_OK uint16 = iota + 1 PING_CLOSED PING_OK_VOID )
Variables ¶
View Source
var ( WithTransport = func(tr http.RoundTripper) Option { return Option(func(d *Dialer, ln *Listener) { if d != nil { d.Transport = tr } }) } WithInactiveTimeout = func(t time.Duration) Option { return Option(func(d *Dialer, ln *Listener) { if d != nil { d.Timeout = t } if ln != nil { ln.Timeout = t } }) } WithWebSocket = func(ws bool) Option { return Option(func(d *Dialer, ln *Listener) { if d != nil { d.WebSocket = ws } }) } WithMaxWriteBuffer = func(size int) Option { return Option(func(d *Dialer, ln *Listener) { if d != nil { d.MaxWriteBuffer = size } if ln != nil { ln.MaxWriteBuffer = size } }) } WithHeader = func(hdr string) Option { return Option(func(d *Dialer, ln *Listener) { if d != nil { d.URLHeader = hdr } }) } WithPathPattern = func(pattern string) Option { return Option(func(d *Dialer, ln *Listener) { if d != nil { d.PathPattern = pattern } }) } WithBadRequest = func(callback http.HandlerFunc) Option { return Option(func(d *Dialer, ln *Listener) { if ln != nil { ln.OnBadRequest = callback } }) } WithBadRequestRoundTripper = func(rt http.RoundTripper) Option { return Option(func(d *Dialer, ln *Listener) { if ln != nil { ln.OnBadRequest = func(w http.ResponseWriter, r *http.Request) { resp, err := rt.RoundTrip(r) if err != nil { w.WriteHeader(http.StatusServiceUnavailable) w.Write([]byte(err.Error())) return } defer resp.Body.Close() w.WriteHeader(resp.StatusCode) for k := range w.Header() { w.Header().Del(k) } for k, v := range resp.Header { hdr := w.Header() for _, v := range v { hdr.Add(k, v) } } io.Copy(w, resp.Body) } } }) } )
View Source
var MaxReadBufferSize = 1024 * 1024 * 1
Define the max pending bytes stored in memory, any further bytes will be written to disk
Functions ¶
Types ¶
type BufConn ¶
func NewBufConn ¶
type ClientConn ¶
type ClientConn struct {
// contains filtered or unexported fields
}
func (*ClientConn) Close ¶
func (c *ClientConn) Close() error
func (*ClientConn) LocalAddr ¶
func (c *ClientConn) LocalAddr() net.Addr
func (*ClientConn) RemoteAddr ¶
func (c *ClientConn) RemoteAddr() net.Addr
func (*ClientConn) SetDeadline ¶
func (c *ClientConn) SetDeadline(t time.Time) error
func (*ClientConn) SetReadDeadline ¶
func (c *ClientConn) SetReadDeadline(t time.Time) error
func (*ClientConn) SetWriteDeadline ¶
func (c *ClientConn) SetWriteDeadline(t time.Time) error
func (*ClientConn) String ¶
func (c *ClientConn) String() string
type CommonOptions ¶
type Dialer ¶
type Dialer struct {
Transport http.RoundTripper
WebSocket bool
URLHeader string
PathPattern string
CommonOptions
// contains filtered or unexported fields
}
type Listener ¶
type Listener struct {
OnBadRequest http.HandlerFunc
CommonOptions
// contains filtered or unexported fields
}
type ServerConn ¶
type ServerConn struct {
// contains filtered or unexported fields
}
func (*ServerConn) Close ¶
func (c *ServerConn) Close() error
func (*ServerConn) LocalAddr ¶
func (c *ServerConn) LocalAddr() net.Addr
func (*ServerConn) RemoteAddr ¶
func (c *ServerConn) RemoteAddr() net.Addr
func (*ServerConn) SetDeadline ¶
func (c *ServerConn) SetDeadline(t time.Time) error
func (*ServerConn) SetReadDeadline ¶
func (c *ServerConn) SetReadDeadline(t time.Time) error
func (*ServerConn) SetWriteDeadline ¶
func (c *ServerConn) SetWriteDeadline(t time.Time) error
func (*ServerConn) String ¶
func (c *ServerConn) String() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.