rewrite

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultRewriteConfig is the default Rewrite middleware config.
	DefaultRewriteConfig = RewriteConfig{}
)

Functions

func Rewrite

func Rewrite(rules map[string]string) gin.HandlerFunc

Rewrite returns a Rewrite middleware. Rewrite middleware rewrites the URL path based on the provided rules.

func RewriteWithConfig

func RewriteWithConfig(config RewriteConfig) gin.HandlerFunc

RewriteWithConfig returns a Rewrite middleware with config.

Types

type RewriteConfig

type RewriteConfig struct {
	// Rules defines the URL path rewrite rules. The values captured in asterisk can be
	// retrieved by index e.g. $1, $2 and so on.
	// Example:
	// "/old":              "/new",
	// "/api/*":            "/$1",
	// "/js/*":             "/public/javascripts/$1",
	// "/users/*/orders/*": "/user/$1/order/$2",
	// Required.
	Rules map[string]string
	// contains filtered or unexported fields
}

RewriteConfig defines the config for Rewrite middleware.

Jump to

Keyboard shortcuts

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