redirect

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package redirect does redirect stuff

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Skipper:   middleware.DefaultSkipper,
	Redirects: map[string]string{},
	Code:      0,
}

DefaultConfig is the default configuration of the redirect middleware

Functions

func New

func New() echo.MiddlewareFunc

New creates a new middleware function with the default config

func NewWithConfig

func NewWithConfig(config Config) echo.MiddlewareFunc

NewWithConfig returns a new router middleware handler

Types

type Config

type Config struct {
	// Enabled indicates if the redirect middleware should be enabled
	Enabled bool `json:"enabled" koanf:"enabled" default:"true"`
	// Skipper defines a function to skip middleware
	Skipper middleware.Skipper `json:"-" koanf:"-"`
	// Redirects is a map of paths to redirect to
	Redirects map[string]string `json:"redirects" koanf:"redirects"`
	// Code is the HTTP status code to use for the redirect
	Code int `json:"code" koanf:"code"`
}

Config contains the types used in executing redirects via the redirect middleware

Jump to

Keyboard shortcuts

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