Documentation
¶
Index ¶
- func NewAccessLogMiddleware(logger *zap.Logger) middleware.Middleware
- func NewHostnameMiddleware(hostname string, logger *zap.Logger) middleware.Middleware
- func NewIPRestrictionMiddleware(allowedIPs []string, logger *zap.Logger) middleware.Middleware
- type AccessLogMiddleware
- type HostnameMiddleware
- type IPRestrictionMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAccessLogMiddleware ¶
func NewAccessLogMiddleware(logger *zap.Logger) middleware.Middleware
func NewHostnameMiddleware ¶
func NewHostnameMiddleware(hostname string, logger *zap.Logger) middleware.Middleware
func NewIPRestrictionMiddleware ¶
func NewIPRestrictionMiddleware(allowedIPs []string, logger *zap.Logger) middleware.Middleware
NewIPRestrictionMiddleware creates a new middleware for IP-based access control
Types ¶
type AccessLogMiddleware ¶
type AccessLogMiddleware struct {
// contains filtered or unexported fields
}
func (*AccessLogMiddleware) Middleware ¶
func (m *AccessLogMiddleware) Middleware(next http.Handler) http.Handler
type HostnameMiddleware ¶
type HostnameMiddleware struct {
// contains filtered or unexported fields
}
HostnameMiddleware validates incoming requests against a configured hostname
func (*HostnameMiddleware) Middleware ¶
func (m *HostnameMiddleware) Middleware(next http.Handler) http.Handler
type IPRestrictionMiddleware ¶
type IPRestrictionMiddleware struct {
// contains filtered or unexported fields
}
IPRestrictionMiddleware validates incoming requests against configured allowed IPs
func (*IPRestrictionMiddleware) Middleware ¶
func (m *IPRestrictionMiddleware) Middleware(next http.Handler) http.Handler
This middleware provides IP-based access control. It validates the client's IP address against a configured list of allowed IPs.
The middleware follows these rules: - If no IPs are configured (allowedIPs is empty), all requests are allowed - If IPs are configured, only requests from those IPs are allowed - Client IP is extracted from X-Forwarded-For header first, then X-Real-IP, finally falling back to RemoteAddr
The function will return an HTTP 403 Forbidden status if the IP is not allowed, or HTTP 500 Internal Server Error if the client IP cannot be determined.