rewrite

package
v2.0.0-beta11 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 9 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rewrite

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

	// Changes the request's URI (path, query string, and fragment if present).
	// Only components of the URI that are specified will be changed.
	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"`

	// If set to a 3xx HTTP status code and if the URI was rewritten (changed),
	// the handler will issue a simple HTTP redirect to the new URI using the
	// given status code.
	HTTPRedirect caddyhttp.WeakString `json:"http_redirect,omitempty"`

	// If true, the request will sent for rehandling after rewriting
	// only if anything about the request was changed.
	Rehandle bool `json:"rehandle,omitempty"`
	// contains filtered or unexported fields
}

Rewrite is a middleware which can rewrite HTTP requests.

The Rehandle and HTTPRedirect properties are mutually exclusive (you cannot both rehandle and issue a redirect).

These rewrite properties are applied to a request in this order: Method, URI, StripPathPrefix, StripPathSuffix, URISubstring.

TODO: This module is still a WIP and may experience breaking changes.

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

func (Rewrite) Validate

func (rewr Rewrite) Validate() error

Validate ensures rewr's configuration is valid.

Jump to

Keyboard shortcuts

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