earlydata.go — fiber Source File
Architecture documentation for earlydata.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 39cc157b_519e_fa46_8768_01f5ac483dbf["earlydata.go"] 6604ba6b_bab7_17c7_e687_7d0f07080e5a["v3"] 39cc157b_519e_fa46_8768_01f5ac483dbf --> 6604ba6b_bab7_17c7_e687_7d0f07080e5a style 39cc157b_519e_fa46_8768_01f5ac483dbf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package earlydata
import (
"github.com/gofiber/fiber/v3"
)
// The contextKey type is unexported to prevent collisions with context keys defined in
// other packages.
type contextKey int
const (
localsKeyAllowed contextKey = 0 // earlydata_allowed
)
// IsEarly returns true if the request used early data and was accepted by the middleware.
func IsEarly(c fiber.Ctx) bool {
return c.Locals(localsKeyAllowed) != nil
}
// New creates a new middleware handler
// https://datatracker.ietf.org/doc/html/rfc8470#section-5.1
func New(config ...Config) fiber.Handler {
// Set default config
cfg := configDefault(config...)
// Return new handler
return func(c fiber.Ctx) error {
// Don't execute middleware if Next returns true
if cfg.Next != nil && cfg.Next(c) {
return c.Next()
}
// Continue stack if request is not an early-data request
if !cfg.IsEarlyData(c) {
return c.Next()
}
// Abort if we can't trust the early-data header
if !c.IsProxyTrusted() {
return cfg.Error
}
// Continue stack if we allow early-data for this request
if cfg.AllowEarlyData(c) {
_ = c.Locals(localsKeyAllowed, true)
return c.Next()
}
// Else return our error
return cfg.Error
}
}
Domain
Subdomains
Types
Dependencies
- v3
Source
Frequently Asked Questions
What does earlydata.go do?
earlydata.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 earlydata.go?
earlydata.go defines 2 function(s): IsEarly, New.
What does earlydata.go depend on?
earlydata.go imports 1 module(s): v3.
Where is earlydata.go in the architecture?
earlydata.go is located at middleware/earlydata/earlydata.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