Middleware

middleware/favicon

github.com/gofiber/fiber/v3/middleware/favicon

import "github.com/gofiber/fiber/v3/middleware/favicon"

Variables

ConfigDefault is the default config

Source: middleware/favicon/config.go:49

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

Functions

func New(config ...Config) fiber.Handler

Source: middleware/favicon/favicon.go:23

New creates a new middleware handler

Types

type Config

Source: middleware/favicon/config.go:10

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"`
}
Fields
  • FileSystem fs.FS `json:"-"`

    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

  • Next func(c fiber.Ctx) bool

    Next defines a function to skip this middleware when returned true.

    Optional. Default: nil

  • File string `json:"file"`

    File holds the path to an actual favicon that will be cached

    Optional. Default: ""

  • URL string `json:"url"`

    URL for favicon handler

    Optional. Default: "/favicon.ico"

  • CacheControl string `json:"cache_control"`

    CacheControl defines how the Cache-Control header in the response should be set

    Optional. Default: "public, max-age=31536000"

  • Data []byte `json:"-"`

    Raw data of the favicon file

    Optional. Default: nil

  • MaxBytes int64 `json:"max_bytes"`

    MaxBytes limits the maximum size of the cached favicon asset.

    Optional. Default: 1048576