Documentation
¶
Index ¶
Constants ¶
const ( // ContextKeyStreamReader is populated in the context by stream reader. ContextKeyStreamReader contextKey = iota + 1 // ContextKeyStreamWriter is populated in the context by stream writer. ContextKeyStreamWriter // ContextKeySessionID is populated in the context by current session id. ContextKeySessionID )
const ( DefaultReTryCount = 10 DefaultHTTPTimeout = 120 * time.Second )
Variables ¶
var ( // ErrStreamReaderNotDefined returned when no stream reader is defined in context. ErrStreamReaderNotDefined = errors.New("httptunnel: stream reader not defined") // ErrStreamWriterNotDefined returned when no stream reader is defined in context. ErrStreamWriterNotDefined = errors.New("httptunnel: stream writer not defined") )
Functions ¶
Types ¶
type ClientOption ¶
type ClientOption func(c *Client)
ClientOption sets an optional parameter for client instance.
func SetReadResponse ¶
func SetReadResponse(r ReadResponse) ClientOption
type ErrorHandler ¶
ErrorHandler receives a transport error to be processed for diagnostic purposes. Usually this means logging the error.
type ErrorHandlerFunc ¶
The ErrorHandlerFunc type is an adapter to allow the use of ordinary function as ErrorHandler. If f is a function with the appropriate signature, ErrorHandlerFunc(f) is a ErrorHandler that calls f.
type LogErrorHandler ¶
type LogErrorHandler struct {
// contains filtered or unexported fields
}
func NewLogErrorHandler ¶
func NewLogErrorHandler() *LogErrorHandler
type ReadRequest ¶
ReadRequest reads and parses an incoming request from b.
type ReadResponse ¶
ReadResponse reads and returns an HTTP response from r.
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
func New ¶
func New( options ...TunnelOption, ) *Tunnel
type TunnelOption ¶
type TunnelOption func(tunnel *Tunnel)
TunnelOption sets an optional parameter for tunnel instance.
func RequestHook ¶ added in v0.2.0
func RequestHook(before ...RequestFunc) TunnelOption
RequestHook functions are executed on the HTTP request object before the request is send.
func ResponseHook ¶ added in v0.2.0
func ResponseHook(after ...ResponseFunc) TunnelOption
ResponseHook functions are executed on the HTTP response writer after the endpoint is invoked, but before anything is written to the client.
func SetClient ¶
func SetClient(client httpclient.Client) TunnelOption
SetClient sets the HTTP client.
func SetReadRequest ¶
func SetReadRequest(r ReadRequest) TunnelOption
SetReadRequest sets the parser for incoming request.
func SetTunnelErrorHandler ¶
func SetTunnelErrorHandler(errorHandler ErrorHandler) TunnelOption
SetTunnelErrorHandler is used to handle non-terminal errors. By default, non-terminal errors are ignored. This is intended as a diagnostic measure.