Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(filename string) router.WrapperFunc
Load decodes the "filename" options and returns a new Rewrite Engine Router Wrapper. It panics on errors. Usage: redirects := Load("redirects.yml") app.WrapRouter(redirects) See `New` too.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the rewrite engine master structure. Navigate through _examples/routing/rewrite for more.
func New ¶
New returns a new Rewrite Engine based on "opts". It reports any parser error. See its `Handler` or `Rewrite` methods. Depending on the needs, select one.
func (*Engine) Handler ¶
Handler is an Iris Handler that can be used as a router or party or route middleware. For a global alternative, if you want to wrap the entire Iris Application use the `Wrapper` instead. Usage: app.UseRouter(engine.Handler)
func (*Engine) Rewrite ¶
func (e *Engine) Rewrite(w http.ResponseWriter, r *http.Request, routeHandler http.HandlerFunc)
Rewrite is used to wrap the entire Iris Router. Rewrite is a bit faster than Handler because it's executed even before any route matched and it stops on redirect pattern match. Use it to wrap the entire Iris Application, otherwise look `Handler` instead.
Usage: app.WrapRouter(engine.Rewrite).
type Options ¶
type Options struct { // RedirectMatch accepts a slice of lines // of form: // REDIRECT_CODE PATH_PATTERN TARGET_PATH // Example: []{"301 /seo/(.*) /$1"}. RedirectMatch []string `json:"redirectMatch" yaml:"RedirectMatch"` // Root domain requests redirect automatically to primary subdomain. // Example: "www" to redirect always to www. // Note that you SHOULD NOT create a www subdomain inside the Iris Application. // This field takes care of it for you, the root application instance // will be used to serve the requests. PrimarySubdomain string `json:"primarySubdomain" yaml:"PrimarySubdomain"` }
Options holds the developer input to customize the redirects for the Rewrite Engine. Look the `New` and `Load` package-level functions.
func LoadOptions ¶
LoadOptions loads rewrite Options from a system file.