Documentation
¶
Overview ¶
Package action implements request handlers (proxy, static, serve, pass, drop).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnStats ¶
type ConnStats struct {
BytesRx int64 // atomic: client → upstream
BytesTx int64 // atomic: upstream → client
}
ConnStats accumulates byte counts from hijacked connection relays. Used only for WebSocket and CONNECT paths where ResponseCapture is bypassed after hijack.
func ConnStatsFromContext ¶
ConnStatsFromContext extracts ConnStats from the context, or nil.
type CountingReader ¶
type CountingReader struct {
N int64
// contains filtered or unexported fields
}
CountingReader wraps an io.ReadCloser and counts bytes read. Not safe for concurrent use — r.Body is read by a single goroutine.
func (*CountingReader) Read ¶
func (cr *CountingReader) Read(p []byte) (int, error)
Read implements io.Reader with byte counting.
func (*CountingReader) Reset ¶
func (cr *CountingReader) Reset(rc io.ReadCloser)
Reset reinitializes the CountingReader for reuse from a pool.
type Drop ¶
type Drop struct{}
Drop aborts the connection without sending any HTTP response. Uses http.ErrAbortHandler which is handled by Go's HTTP server:
- HTTP/1.1: connection is closed with no response written
- HTTP/2: stream is reset (RST_STREAM)
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy forwards requests to an upstream server. WebSocket upgrades are detected and handled via bidirectional TCP relay.
When the upstream contains template placeholders (e.g. {target}), they are resolved per-request from the route's balancer and set variables.
func NewProxy ¶
NewProxy creates a reverse proxy handler for the given action config. svcCfg provides optional service-level transport tuning.
func (*Proxy) SetFallback ¶
SetFallback sets the handler invoked when the primary action fails.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps action names to their http.Handler implementations.
func Build ¶
func Build(actions map[string]*config.Action, resolver *resource.Resolver, hints *RouteHints, svcCfg *config.ServerConfig) (*Registry, error)
Build constructs all action handlers from config. svcCfg is optional service-level configuration for transport tuning.
type RouteHints ¶
RouteHints maps action names to route paths for prefix stripping.
type Serve ¶
type Serve struct {
// contains filtered or unexported fields
}
Serve is an action that serves files from a directory or a single file.
type Static ¶
type Static struct {
// contains filtered or unexported fields
}
Static returns a fixed response with pre-computed body, headers, and status. If the body contains template variables like {domain}, {match.domain}, {path}, {match.path}, {method}, they are interpolated at request time.