config.go — fiber Source File
Architecture documentation for config.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2d1f2031_965a_d14b_2256_317dd34f22ca["config.go"] 6604ba6b_bab7_17c7_e687_7d0f07080e5a["v3"] 2d1f2031_965a_d14b_2256_317dd34f22ca --> 6604ba6b_bab7_17c7_e687_7d0f07080e5a style 2d1f2031_965a_d14b_2256_317dd34f22ca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package earlydata
import (
"github.com/gofiber/fiber/v3"
)
const (
DefaultHeaderName = "Early-Data"
DefaultHeaderTrueValue = "1"
)
// Config defines the config for middleware.
type Config struct {
// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next func(c fiber.Ctx) bool
// IsEarlyData returns whether the request is an early-data request.
//
// Optional. Default: a function which checks if the "Early-Data" request header equals "1".
IsEarlyData func(c fiber.Ctx) bool
// AllowEarlyData returns whether the early-data request should be allowed or rejected.
//
// Optional. Default: a function which rejects the request on unsafe and allows the request on safe HTTP request methods.
AllowEarlyData func(c fiber.Ctx) bool
// Error is returned if an early-data request is rejected.
//
// Optional. Default: fiber.ErrTooEarly.
Error error
}
// ConfigDefault is the default config
var ConfigDefault = Config{
IsEarlyData: func(c fiber.Ctx) bool {
return c.Get(DefaultHeaderName) == DefaultHeaderTrueValue
},
AllowEarlyData: func(c fiber.Ctx) bool {
return fiber.IsMethodSafe(c.Method())
},
Error: fiber.ErrTooEarly,
}
// Helper function to set default values
func configDefault(config ...Config) Config {
// Return default config if nothing provided
if len(config) < 1 {
return ConfigDefault
}
// Override default config
cfg := config[0]
// Set default values
if cfg.IsEarlyData == nil {
cfg.IsEarlyData = ConfigDefault.IsEarlyData
}
if cfg.AllowEarlyData == nil {
cfg.AllowEarlyData = ConfigDefault.AllowEarlyData
}
if cfg.Error == nil {
cfg.Error = ConfigDefault.Error
}
return cfg
}
Domain
Subdomains
Functions
Classes
Types
Dependencies
- v3
Source
Frequently Asked Questions
What does config.go do?
config.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Adapters subdomain.
What functions are defined in config.go?
config.go defines 2 function(s): bool, configDefault.
What does config.go depend on?
config.go imports 1 module(s): v3.
Where is config.go in the architecture?
config.go is located at middleware/earlydata/config.go (domain: FiberCore, subdomain: Adapters, directory: middleware/earlydata).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free