rewrite

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rewrite is middleware for rewriting requests internally to a different path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RegexpRule added in v0.7.0

type RegexpRule struct {
	// Path base. Request to this path and subpaths will be rewritten
	Base string

	// Path to rewrite to
	To string

	// Extensions to filter by
	Exts []string

	*regexp.Regexp
}

RegexpRule is a rewrite rule based on a regular expression

func NewRegexpRule added in v0.7.0

func NewRegexpRule(base, pattern, to string, ext []string) (*RegexpRule, error)

NewRegexpRule creates a new RegexpRule. It returns an error if regexp pattern (pattern) or extensions (ext) are invalid.

func (*RegexpRule) Rewrite added in v0.7.0

func (r *RegexpRule) Rewrite(req *http.Request) bool

Rewrite rewrites the internal location of the current request.

type Rewrite

type Rewrite struct {
	Next  middleware.Handler
	Rules []Rule
}

Rewrite is middleware to rewrite request locations internally before being handled.

func (Rewrite) ServeHTTP

func (rw Rewrite) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

ServeHTTP implements the middleware.Handler interface.

type Rule added in v0.6.0

type Rule interface {
	// Rewrite rewrites the internal location of the current request.
	Rewrite(*http.Request) bool
}

Rule describes an internal location rewrite rule.

type SimpleRule added in v0.7.0

type SimpleRule struct {
	From, To string
}

SimpleRule is a simple rewrite rule.

func NewSimpleRule added in v0.7.0

func NewSimpleRule(from, to string) SimpleRule

NewSimpleRule creates a new Simple Rule

func (SimpleRule) Rewrite added in v0.7.0

func (s SimpleRule) Rewrite(r *http.Request) bool

Rewrite rewrites the internal location of the current request.

Jump to

Keyboard shortcuts

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