Home / File/ config.go — fiber Source File

config.go — fiber Source File

Architecture documentation for config.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Adapters 1 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  b6e1f0a4_8d3a_15a6_ab1f_58af747f4ca9["config.go"]
  91e028e2_bdf9_8fcd_cf03_c8d86daaec3f["fs"]
  b6e1f0a4_8d3a_15a6_ab1f_58af747f4ca9 --> 91e028e2_bdf9_8fcd_cf03_c8d86daaec3f
  style b6e1f0a4_8d3a_15a6_ab1f_58af747f4ca9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package favicon

import (
	"io/fs"

	"github.com/gofiber/fiber/v3"
)

// Config defines the config for middleware.
type Config struct {
	// FileSystem is an optional alternate filesystem to search for the favicon in.
	// An example of this could be an embedded or network filesystem
	//
	// Optional. Default: nil
	FileSystem fs.FS `json:"-"`

	// Next defines a function to skip this middleware when returned true.
	//
	// Optional. Default: nil
	Next func(c fiber.Ctx) bool

	// File holds the path to an actual favicon that will be cached
	//
	// Optional. Default: ""
	File string `json:"file"`

	// URL for favicon handler
	//
	// Optional. Default: "/favicon.ico"
	URL string `json:"url"`

	// CacheControl defines how the Cache-Control header in the response should be set
	//
	// Optional. Default: "public, max-age=31536000"
	CacheControl string `json:"cache_control"`

	// Raw data of the favicon file
	//
	// Optional. Default: nil
	Data []byte `json:"-"`

	// MaxBytes limits the maximum size of the cached favicon asset.
	//
	// Optional. Default: 1048576
	MaxBytes int64 `json:"max_bytes"`
}

// ConfigDefault is the default config
var ConfigDefault = Config{
	Next:         nil,
	File:         "",
	URL:          fPath,
	CacheControl: "public, max-age=31536000",
	MaxBytes:     1024 * 1024,
}

func configDefault(config ...Config) Config {
	if len(config) == 0 {
		return ConfigDefault
	}

	cfg := config[0]

	if cfg.Next == nil {
		cfg.Next = ConfigDefault.Next
	}
	if cfg.URL == "" {
		cfg.URL = ConfigDefault.URL
	}
	if cfg.File == "" {
		cfg.File = ConfigDefault.File
	}
	if cfg.CacheControl == "" {
		cfg.CacheControl = ConfigDefault.CacheControl
	}
	if cfg.MaxBytes <= 0 {
		cfg.MaxBytes = ConfigDefault.MaxBytes
	}

	return cfg
}

Domain

Subdomains

Classes

Types

Dependencies

  • fs

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): fs.
Where is config.go in the architecture?
config.go is located at middleware/favicon/config.go (domain: FiberCore, subdomain: Adapters, directory: middleware/favicon).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free