Documentation
¶
Index ¶
- Constants
- Variables
- func All() map[string]*Middleware
- func BuildMiddlewaresFromComposeFile(filePath string, eb *E.Builder) map[string]*Middleware
- func BuildMiddlewaresFromYAML(source string, data []byte, eb *E.Builder) map[string]*Middleware
- func Get(name string) (*Middleware, Error)
- func LoadComposeFiles()
- func PatchReverseProxy(rp *ReverseProxy, middlewaresMap map[string]OptionsRaw) (err E.Error)
- func ServeStaticErrorPageFile(w http.ResponseWriter, r *http.Request) (served bool)
- type ByPriority
- type CIDRWhitelistOpts
- type Error
- type ForwardAuthOpts
- type ImplNewFunc
- type Middleware
- func BuildMiddlewareFromChainRaw(name string, defs []map[string]any) (*Middleware, E.Error)
- func BuildMiddlewareFromMap(name string, middlewaresMap map[string]OptionsRaw) (*Middleware, E.Error)
- func NewMiddleware[ImplType any]() *Middleware
- func NewMiddlewareChain(name string, chain []*Middleware) *Middleware
- func (m *Middleware) MarshalJSON() ([]byte, error)
- func (m *Middleware) ModifyRequest(next http.HandlerFunc, w http.ResponseWriter, r *http.Request)
- func (m *Middleware) ModifyResponse(resp *http.Response) error
- func (m *Middleware) Name() string
- func (m *Middleware) New(optsRaw OptionsRaw) (*Middleware, E.Error)
- func (m *Middleware) ServeHTTP(next http.HandlerFunc, w http.ResponseWriter, r *http.Request)
- func (m *Middleware) String() string
- type MiddlewareFinalizer
- type MiddlewareFinalizerWithError
- type MiddlewareWithSetup
- type MiddlewareWithTracer
- type ModifyRequestOpts
- type OptionsRaw
- type ProxyRequest
- type RateLimiterOpts
- type RealIPOpts
- type RequestModifier
- type ResponseModifier
- type ReverseProxy
- type TestResult
- type Trace
- type Tracer
- type Traces
Constants ¶
View Source
const ( VarRequestMethod = "$req_method" VarRequestScheme = "$req_scheme" VarRequestHost = "$req_host" VarRequestPort = "$req_port" VarRequestPath = "$req_path" VarRequestAddr = "$req_addr" VarRequestQuery = "$req_query" VarRequestURL = "$req_url" VarRequestURI = "$req_uri" VarRequestContentType = "$req_content_type" VarRequestContentLen = "$req_content_length" VarRemoteHost = "$remote_host" VarRemotePort = "$remote_port" VarRemoteAddr = "$remote_addr" VarUpstreamName = "$upstream_name" VarUpstreamScheme = "$upstream_scheme" VarUpstreamHost = "$upstream_host" VarUpstreamPort = "$upstream_port" VarUpstreamAddr = "$upstream_addr" VarUpstreamURL = "$upstream_url" VarRespContentType = "$resp_content_type" VarRespContentLen = "$resp_content_length" VarRespStatusCode = "$status_code" )
View Source
const DefaultPriority = 10
View Source
const MaxTraceNum = 100
Variables ¶
View Source
var ( ErrUnknownMiddleware = E.New("unknown middleware") ErrDuplicatedMiddleware = E.New("duplicated middleware") )
View Source
var ( SetXForwarded = NewMiddleware[setXForwarded]() HideXForwarded = NewMiddleware[hideXForwarded]() )
View Source
var (
CIDRWhiteList = NewMiddleware[cidrWhitelist]()
)
View Source
var CloudflareRealIP = NewMiddleware[cloudflareRealIP]()
View Source
var CustomErrorPage = NewMiddleware[customErrorPage]()
View Source
var ErrMissingMiddlewareUse = E.New("missing middleware 'use' field")
View Source
var ForwardAuth = NewMiddleware[forwardAuth]()
View Source
var ModifyRequest = NewMiddleware[modifyRequest]()
View Source
var ModifyResponse = NewMiddleware[modifyResponse]()
View Source
var OIDC = NewMiddleware[oidcMiddleware]()
View Source
var (
RateLimiter = NewMiddleware[rateLimiter]()
)
View Source
var (
RealIP = NewMiddleware[realIP]()
)
View Source
var RedirectHTTP = NewMiddleware[redirectHTTP]()
Functions ¶
func All ¶
func All() map[string]*Middleware
func BuildMiddlewaresFromComposeFile ¶
func BuildMiddlewaresFromComposeFile(filePath string, eb *E.Builder) map[string]*Middleware
func Get ¶
func Get(name string) (*Middleware, Error)
func LoadComposeFiles ¶
func LoadComposeFiles()
func PatchReverseProxy ¶
func PatchReverseProxy(rp *ReverseProxy, middlewaresMap map[string]OptionsRaw) (err E.Error)
func ServeStaticErrorPageFile ¶
func ServeStaticErrorPageFile(w http.ResponseWriter, r *http.Request) (served bool)
Types ¶
type ByPriority ¶
type ByPriority []*Middleware
func (ByPriority) Len ¶
func (m ByPriority) Len() int
func (ByPriority) Less ¶
func (m ByPriority) Less(i, j int) bool
func (ByPriority) Swap ¶
func (m ByPriority) Swap(i, j int)
type CIDRWhitelistOpts ¶
type ForwardAuthOpts ¶
type ImplNewFunc ¶
type ImplNewFunc = func() any
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func BuildMiddlewareFromChainRaw ¶
TODO: check conflict or duplicates.
func BuildMiddlewareFromMap ¶
func BuildMiddlewareFromMap(name string, middlewaresMap map[string]OptionsRaw) (*Middleware, E.Error)
func NewMiddleware ¶
func NewMiddleware[ImplType any]() *Middleware
func NewMiddlewareChain ¶
func NewMiddlewareChain(name string, chain []*Middleware) *Middleware
TODO: check conflict or duplicates.
func (*Middleware) MarshalJSON ¶
func (m *Middleware) MarshalJSON() ([]byte, error)
func (*Middleware) ModifyRequest ¶
func (m *Middleware) ModifyRequest(next http.HandlerFunc, w http.ResponseWriter, r *http.Request)
func (*Middleware) ModifyResponse ¶
func (m *Middleware) ModifyResponse(resp *http.Response) error
func (*Middleware) Name ¶
func (m *Middleware) Name() string
func (*Middleware) New ¶
func (m *Middleware) New(optsRaw OptionsRaw) (*Middleware, E.Error)
func (*Middleware) ServeHTTP ¶
func (m *Middleware) ServeHTTP(next http.HandlerFunc, w http.ResponseWriter, r *http.Request)
func (*Middleware) String ¶
func (m *Middleware) String() string
type MiddlewareFinalizer ¶
type MiddlewareFinalizer interface {
// contains filtered or unexported methods
}
type MiddlewareFinalizerWithError ¶
type MiddlewareFinalizerWithError interface {
// contains filtered or unexported methods
}
type MiddlewareWithSetup ¶
type MiddlewareWithSetup interface {
// contains filtered or unexported methods
}
type MiddlewareWithTracer ¶
type MiddlewareWithTracer interface {
// contains filtered or unexported methods
}
type ModifyRequestOpts ¶
type ModifyRequestOpts struct { SetHeaders map[string]string AddHeaders map[string]string HideHeaders []string AddPrefix string // contains filtered or unexported fields }
order: add_prefix -> set_headers -> add_headers -> hide_headers
type OptionsRaw ¶
type ProxyRequest ¶
type ProxyRequest = reverseproxy.ProxyRequest
type RateLimiterOpts ¶
type RealIPOpts ¶
type RealIPOpts struct { // Header is the name of the header to use for the real client IP Header string `validate:"required"` // From is a list of Address / CIDRs to trust From []*types.CIDR `validate:"required,min=1"` /* If recursive search is disabled, the original client address that matches one of the trusted addresses is replaced by the last address sent in the request header field defined by the Header field. If recursive search is enabled, the original client address that matches one of the trusted addresses is replaced by the last non-trusted address sent in the request header field. */ Recursive bool }
type RequestModifier ¶
type RequestModifier interface {
// contains filtered or unexported methods
}
type ResponseModifier ¶
type ResponseModifier interface {
// contains filtered or unexported methods
}
type ReverseProxy ¶
type ReverseProxy = reverseproxy.ReverseProxy
type TestResult ¶
type Trace ¶
type Trace struct { Time string `json:"time,omitempty"` Caller string `json:"caller,omitempty"` URL string `json:"url,omitempty"` Message string `json:"msg"` ReqHeaders map[string]string `json:"req_headers,omitempty"` RespHeaders map[string]string `json:"resp_headers,omitempty"` RespStatus int `json:"resp_status,omitempty"` Additional map[string]any `json:"additional,omitempty"` }
func GetAllTrace ¶
func GetAllTrace() []*Trace
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
func (*Tracer) AddTraceRequest ¶
func (*Tracer) AddTraceResponse ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.