middleware/earlydata
import "github.com/gofiber/fiber/v3/middleware/earlydata"
Constants
Source: middleware/earlydata/config.go:8
const (
DefaultHeaderName = "Early-Data"
DefaultHeaderTrueValue = "1"
)Variables
ConfigDefault is the default config
Source: middleware/earlydata/config.go:36
var ConfigDefault = Config{
IsEarlyData: func(c fiber.Ctx) bool {
return c.Get(DefaultHeaderName) == DefaultHeaderTrueValue
},
AllowEarlyData: func(c fiber.Ctx) bool {
return c.IsSafe()
},
Error: fiber.ErrTooEarly,
}Functions
func IsEarly(c fiber.Ctx) bool
Source: middleware/earlydata/earlydata.go:17
IsEarly returns true if the request used early data and was accepted by the middleware.
func New(config ...Config) fiber.Handler
Source: middleware/earlydata/earlydata.go:23
New creates a new middleware handler https://datatracker.ietf.org/doc/html/rfc8470#section-5.1
Types
type Config
Source: middleware/earlydata/config.go:13
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
}Fields
Next func(c fiber.Ctx) boolNext defines a function to skip this middleware when returned true.
Optional. Default: nil
IsEarlyData func(c fiber.Ctx) boolIsEarlyData returns whether the request is an early-data request.
Optional. Default: a function which checks if the "Early-Data" request header equals "1".
AllowEarlyData func(c fiber.Ctx) boolAllowEarlyData 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.
Error errorError is returned if an early-data request is rejected.
Optional. Default: fiber.ErrTooEarly.