Signatures
Usage
Basic Usage
Skip Multiple Paths
Skip by Method
Skip by Header
Skip by Path Prefix
Parameters
handler
exclude
c.Next() is called. If nil, the handler is always executed.
Common Use Cases
Skip Health Check Endpoints
Skip Authentication for Public Routes
Skip CORS for Same-Origin Requests
Skip Rate Limiting for Authenticated Users
Skip Compression for Small Responses
Development vs Production
Skip by IP Address
Conditional CSRF Protection
Best Practices
Use Helper Functions
Combine Multiple Conditions
Use with Path Matching
Document Skip Logic
Comparison with Next
Many Fiber middleware have a built-inNext configuration option. The Skip middleware provides an alternative approach:
Using Next (built-in)
Using Skip (wrapper)
Next when configuring individual middleware, and use skip.New() when wrapping middleware that doesn’t have a Next option or when you want to conditionally apply third-party middleware.
Notes
- If the exclude function is nil, the handler is always executed
- The skip middleware is a lightweight wrapper that adds minimal overhead
- This is useful for conditionally applying middleware without modifying its configuration
- The predicate function is evaluated on every request, so keep it efficient