internal

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB

	ENV_PREFIX = "THRUSTER_"
)

Variables

This section is empty.

Functions

func NewCompressionGuardHandler added in v0.1.17

func NewCompressionGuardHandler(next http.Handler) http.Handler

func NewCompressionHandler added in v0.1.17

func NewCompressionHandler(jitter int, disableOnAuth bool, next http.Handler) http.Handler

func NewHandler

func NewHandler(options HandlerOptions) http.Handler

func NewProxyHandler

func NewProxyHandler(targetUrl *url.URL, badGatewayPage string, forwardHeaders bool) http.Handler

func NewRequestStartHandler added in v0.1.17

func NewRequestStartHandler(next http.Handler) http.Handler

func NewStashingWriter

func NewStashingWriter(limit int, dest io.Writer) *stashingWriter

func ProxyErrorHandler

func ProxyErrorHandler(badGatewayPage string) func(w http.ResponseWriter, r *http.Request, err error)

Types

type Cache

type Cache interface {
	Get(key CacheKey) ([]byte, bool)
	Set(key CacheKey, value []byte, expiresAt time.Time)
}

type CacheHandler

type CacheHandler struct {
	// contains filtered or unexported fields
}

func NewCacheHandler

func NewCacheHandler(cache Cache, maxBodySize int, next http.Handler) *CacheHandler

func (*CacheHandler) ServeHTTP

func (h *CacheHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type CacheKey added in v0.0.2

type CacheKey uint64

type CacheableResponse

type CacheableResponse struct {
	StatusCode    int
	HttpHeader    http.Header
	Body          []byte
	VariantHeader http.Header
	// contains filtered or unexported fields
}

func CacheableResponseFromBuffer

func CacheableResponseFromBuffer(b []byte) (CacheableResponse, error)

func NewCacheableResponse

func NewCacheableResponse(w http.ResponseWriter, maxBodyLength int) *CacheableResponse

func (*CacheableResponse) CacheStatus

func (c *CacheableResponse) CacheStatus() (bool, time.Time)

func (*CacheableResponse) Flush added in v0.1.15

func (c *CacheableResponse) Flush()

func (*CacheableResponse) Header

func (c *CacheableResponse) Header() http.Header

func (*CacheableResponse) ToBuffer

func (c *CacheableResponse) ToBuffer() ([]byte, error)

func (*CacheableResponse) Write

func (c *CacheableResponse) Write(bytes []byte) (int, error)

func (*CacheableResponse) WriteCachedResponse

func (c *CacheableResponse) WriteCachedResponse(w http.ResponseWriter, r *http.Request)

func (*CacheableResponse) WriteHeader

func (c *CacheableResponse) WriteHeader(statusCode int)

type Config

type Config struct {
	TargetPort      int
	UpstreamCommand string
	UpstreamArgs    []string

	CacheSizeBytes               int
	MaxCacheItemSizeBytes        int
	XSendfileEnabled             bool
	GzipCompressionEnabled       bool
	GzipCompressionDisableOnAuth bool
	GzipCompressionJitter        int
	MaxRequestBody               int

	TLSDomains       []string
	ACMEDirectoryURL string
	EAB_KID          string
	EAB_HMACKey      string
	StoragePath      string
	BadGatewayPage   string

	HttpPort         int
	HttpsPort        int
	HttpIdleTimeout  time.Duration
	HttpReadTimeout  time.Duration
	HttpWriteTimeout time.Duration

	H2CEnabled bool

	ForwardHeaders bool

	LogLevel    slog.Level
	LogRequests bool
}

func NewConfig

func NewConfig() (*Config, error)

func (*Config) HasTLS added in v0.1.8

func (c *Config) HasTLS() bool

type GetCurrentTime

type GetCurrentTime func() time.Time

type HandlerOptions

type HandlerOptions struct {
	// contains filtered or unexported fields
}

type LoggingHandler added in v0.1.17

type LoggingHandler struct {
	// contains filtered or unexported fields
}

func NewLoggingHandler added in v0.1.17

func NewLoggingHandler(logger *slog.Logger, next http.Handler) *LoggingHandler

func (*LoggingHandler) ServeHTTP added in v0.1.17

func (h *LoggingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MemoryCache

type MemoryCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMemoryCache

func NewMemoryCache(capacity, maxItemSize int) *MemoryCache

func (*MemoryCache) Get

func (c *MemoryCache) Get(key CacheKey) ([]byte, bool)

func (*MemoryCache) Set

func (c *MemoryCache) Set(key CacheKey, value []byte, expiresAt time.Time)

type MemoryCacheEntry

type MemoryCacheEntry struct {
	// contains filtered or unexported fields
}

type MemoryCacheEntryMap

type MemoryCacheEntryMap map[CacheKey]*MemoryCacheEntry

type MemoryCacheKeyList

type MemoryCacheKeyList []CacheKey

type SendfileHandler

type SendfileHandler struct {
	// contains filtered or unexported fields
}

func NewSendfileHandler

func NewSendfileHandler(enabled bool, next http.Handler) *SendfileHandler

func (*SendfileHandler) ServeHTTP

func (h *SendfileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *Config, handler http.Handler) *Server

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(config *Config) *Service

func (*Service) Run

func (s *Service) Run() int

type UpstreamProcess

type UpstreamProcess struct {
	Started chan struct{}
	// contains filtered or unexported fields
}

func NewUpstreamProcess

func NewUpstreamProcess(name string, arg ...string) *UpstreamProcess

func (*UpstreamProcess) Run

func (p *UpstreamProcess) Run() (int, error)

func (*UpstreamProcess) Signal

func (p *UpstreamProcess) Signal(sig os.Signal) error

type Variant added in v0.0.2

type Variant struct {
	// contains filtered or unexported fields
}

func NewVariant added in v0.0.2

func NewVariant(r *http.Request) *Variant

func (*Variant) CacheKey added in v0.0.2

func (v *Variant) CacheKey() CacheKey

func (*Variant) Matches added in v0.0.2

func (v *Variant) Matches(responseHeader http.Header) bool

func (*Variant) SetResponseHeader added in v0.0.2

func (v *Variant) SetResponseHeader(header http.Header)

func (*Variant) VariantHeader added in v0.0.2

func (v *Variant) VariantHeader() http.Header

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL