middlewares

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultEtagConfig is the default Etag middleware config.
	DefaultEtagConfig = EtagConfig{
		Skipper: middleware.DefaultSkipper,
		Weak:    true,
		HashFn: func(config EtagConfig) hash.Hash {
			if config.Weak {
				const crcPol = 0xD5828281
				crc32qTable := crc32.MakeTable(crcPol)
				return crc32.New(crc32qTable)
			}
			return sha256.New()
		},
	}
)

Functions

func AuthWithConfig

func AuthWithConfig(config AuthConfig) echo.MiddlewareFunc

AuthWithConfig returns a middleware which authenticates requests.

func Etag added in v1.2.0

func Etag() echo.MiddlewareFunc

Etag returns a Etag middleware.

func Healthz

func Healthz(rs ...Resource) echo.MiddlewareFunc

Healthz create a health check middleware

func RedirectRepository

func RedirectRepository(config configs.Configuration) echo.MiddlewareFunc

RedirectRepository redirect to frontend repository when request path is a docker pull path Note: namespace MUST be not 'api' or 'v2'

func WithEtagConfig added in v1.2.0

func WithEtagConfig(config EtagConfig) echo.MiddlewareFunc

WithEtagConfig returns a Etag middleware with config.

Types

type AuthConfig

type AuthConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper
	// DS is distribution service or not.
	DS bool
}

AuthConfig is the configuration for the Auth middleware.

type EtagConfig added in v1.2.0

type EtagConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper
	// Weak defines if the Etag is weak or strong.
	Weak bool
	// HashFn defines the hash function to use. Default is crc32q.
	HashFn func(config EtagConfig) hash.Hash
}

EtagConfig defines the config for Etag middleware.

type Resource

type Resource interface {
	HealthCheck() error // returns error if health check no passed
}

Resource something that need be health checked

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL