Version: v2.1.0-unotech Latest Latest

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

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 8 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Rewrite

type Rewrite struct {
	// Changes the request's HTTP verb.
	Method string `json:"method,omitempty"`

	// Changes the request's URI, which consists of path and query string.
	// Only components of the URI that are specified will be changed.
	// For example, a value of "/foo.html" or "foo.html" will only change
	// the path and will preserve any existing query string. Similarly, a
	// value of "?a=b" will only change the query string and will not affect
	// the path. Both can also be changed: "/foo?a=b" - this sets both the
	// path and query string at the same time.
	// You can also use placeholders. For example, to preserve the existing
	// query string, you might use: "?{http.request.uri.query}&a=b". Any
	// key-value pairs you add to the query string will not overwrite
	// existing values (individual pairs are append-only).
	// To clear the query string, explicitly set an empty one: "?"
	URI string `json:"uri,omitempty"`

	// Strips the given prefix from the beginning of the URI path.
	StripPathPrefix string `json:"strip_path_prefix,omitempty"`

	// Strips the given suffix from the end of the URI path.
	StripPathSuffix string `json:"strip_path_suffix,omitempty"`

	// Performs substring replacements on the URI.
	URISubstring []replacer `json:"uri_substring,omitempty"`
	// contains filtered or unexported fields

Rewrite is a middleware which can rewrite HTTP requests.

The Method and URI properties are "setters": the request URI will be set to the given values. Other properties are "modifiers": they modify existing files but do not explicitly specify what the result will be. It is atypical to combine the use of setters and modifiers in a single rewrite.

func (Rewrite) CaddyModule

func (Rewrite) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Rewrite) Provision

func (rewr *Rewrite) Provision(ctx caddy.Context) error

Provision sets up rewr.

func (Rewrite) ServeHTTP

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

Jump to

Keyboard shortcuts

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