maphandler

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Source is a placeholder
	Source string `json:"source,omitempty"`
	// Destination is a new placeholder
	Destination string `json:"destination,omitempty"`
	// Default is an optional value to use if no other was found
	Default string `json:"default,omitempty"`
	// Items is an array of regex expressions and values
	Items []Item `json:"items,omitempty"`
}

Handler is a middleware that maps a source placeholder to a destination placeholder.

The mapping process happens early in the request handling lifecycle so that the Destination placeholder is calculated and available for substitution. The Items array contains pairs of regex expressions and values, the Source is matched against the expression, if they match then the destination placeholder is set to the value.

The Default is optional, if no Item expression is matched then the value of the Default will be used.

func (Handler) CaddyModule

func (Handler) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Handler) Provision

func (h *Handler) Provision(_ caddy.Context) error

Provision will compile all regular expressions

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

type Item

type Item struct {
	// Expression is the regular expression searched for
	Expression string `json:"expression,omitempty"`
	// Value to use once the expression has been found
	Value string `json:"value,omitempty"`
	// contains filtered or unexported fields
}

Item defines each entry in the map

Jump to

Keyboard shortcuts

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