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 f6963597_c994_df19_3697_223c26cfd16e["config.go"] 6604ba6b_bab7_17c7_e687_7d0f07080e5a["v3"] f6963597_c994_df19_3697_223c26cfd16e --> 6604ba6b_bab7_17c7_e687_7d0f07080e5a style f6963597_c994_df19_3697_223c26cfd16e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package encryptcookie
import (
"github.com/gofiber/fiber/v3"
)
// 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
// Custom function to encrypt cookies.
//
// Optional. Default: EncryptCookie (using AES-GCM)
Encryptor func(name, decryptedString, key string) (string, error)
// Custom function to decrypt cookies.
//
// Optional. Default: DecryptCookie (using AES-GCM)
Decryptor func(name, encryptedString, key string) (string, error)
// Base64 encoded unique key to encode & decode cookies.
//
// Required. Key length should be 16, 24, or 32 bytes when decoded
// if using the default EncryptCookie and DecryptCookie functions.
// You may use `encryptcookie.GenerateKey(length)` to generate a new key.
Key string
// Array of cookie keys that should not be encrypted.
//
// Optional. Default: []
Except []string
}
// ConfigDefault is the default config
var ConfigDefault = Config{
Next: nil,
Except: []string{},
Key: "",
Encryptor: EncryptCookie,
Decryptor: DecryptCookie,
}
// Helper function to set default values
func configDefault(config ...Config) Config {
// Set default config
cfg := ConfigDefault
// Override config if provided
if len(config) > 0 {
cfg = config[0]
// Set default values
if cfg.Next == nil {
cfg.Next = ConfigDefault.Next
}
if cfg.Except == nil {
cfg.Except = ConfigDefault.Except
}
if cfg.Encryptor == nil {
cfg.Encryptor = ConfigDefault.Encryptor
}
if cfg.Decryptor == nil {
cfg.Decryptor = ConfigDefault.Decryptor
}
}
if cfg.Key == "" {
panic("fiber: encrypt cookie middleware requires key")
}
if err := validateKey(cfg.Key); err != nil {
panic(err)
}
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 3 function(s): bool, configDefault, name.
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/encryptcookie/config.go (domain: FiberCore, subdomain: Adapters, directory: middleware/encryptcookie).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free