redirect

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package redirect provides compiling and matching redirect and rewrite rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher for header lookup.

func Compile

func Compile(rules Rules) (*Matcher, error)

Compile the given rules to a trie.

func (*Matcher) Lookup

func (m *Matcher) Lookup(path string) *Rule

Lookup returns fields for the given path.

type Rule

type Rule struct {
	Path     string `json:"path"`
	Location string `json:"location"`
	Status   int    `json:"status"`
	Force    bool   `json:"force"`
	// contains filtered or unexported fields
}

Rule is a single redirect rule.

func (*Rule) Compile

func (r *Rule) Compile()

Compile the rule.

func (*Rule) IsDynamic

func (r *Rule) IsDynamic() bool

IsDynamic returns true if a splat or placeholder is used.

func (*Rule) IsRewrite

func (r *Rule) IsRewrite() bool

IsRewrite returns true if the rule represents a rewrite.

func (Rule) URL

func (r Rule) URL(path string) string

URL returns the final destination after substitutions from path.

type Rules

type Rules map[string]Rule

Rules map of paths to redirects.

Jump to

Keyboard shortcuts

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