middleware

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalBlockList = &IPBlockList{
	blocked: make(map[string]bool),
}

Functions

func BotChallengeHandler

func BotChallengeHandler(w http.ResponseWriter, r *http.Request)

BotChallengeHandler handles the POST request from the challenge page

func BotDefense

func BotDefense(next http.Handler) http.Handler

BotDefense implements a simple JS challenge to stop basic bots

func HostDispatcher

func HostDispatcher(next http.Handler) http.Handler

HostDispatcher performs an O(1) lookup to route requests based on the Host header. This is much more efficient than linear middleware checks for environments with many domains.

func IPBlocker

func IPBlocker(next http.Handler) http.Handler

IPBlocker Middleware

func InjectAuthToScope

func InjectAuthToScope(r *http.Request, scope interface{})

InjectAuthToScope injects auth data from HTTP context into ZenoLang scope This should be called in createHandler before executing ZenoLang code

func MultiTenantAuth

func MultiTenantAuth(jwtSecret string) func(http.Handler) http.Handler

MultiTenantAuth is a Chi middleware that handles multi-tenant authentication It auto-detects tenant from X-Tenant-ID header or subdomain, validates JWT token, and sets auth context for downstream handlers

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer adalah middleware custom untuk ZenoEngine

func SecurityHeaders

func SecurityHeaders(next http.Handler) http.Handler

SecurityHeaders adds "Helmet"-like security headers

func WAF

func WAF(next http.Handler) http.Handler

WAF is a lightweight Web Application Firewall middleware

Types

type IPBlockList

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

IPBlockList manages blocked IPs safely

func (*IPBlockList) Add

func (b *IPBlockList) Add(ip string)

Add blocks an IP dynamically

func (*IPBlockList) IsBlocked

func (b *IPBlockList) IsBlocked(ip string) bool

IsBlocked checks if an IP is in the blocklist

func (*IPBlockList) Load

func (b *IPBlockList) Load()

LoadBlockList initializes the blocklist from Env and File

func (*IPBlockList) Remove

func (b *IPBlockList) Remove(ip string)

Remove unblocks an IP

Jump to

Keyboard shortcuts

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