mod_redirect

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EXCLUSIVE_ACTIONS = map[string]interface{}{
	"SCHEME_SET":     nil,
	"URL_SET":        nil,
	"URL_FROM_QUERY": nil,
	"URL_PREFIX_ADD": nil,
}

exclusive action set

Functions

func ActionFileCheck

func ActionFileCheck(conf ActionFile) error

func ActionFileListCheck

func ActionFileListCheck(conf *ActionFileList) error

func ConfModRedirectCheck

func ConfModRedirectCheck(cfg *ConfModRedirect, confRoot string) error

func PrepareReqRedirect

func PrepareReqRedirect(req *bfe_basic.Request, rules *RuleList) bool

PrepareReqRedirect do redirect to http request, with given redirect rules.

func ProductRulesCheck

func ProductRulesCheck(conf *ProductRulesFile) error

func RedirectConfCheck

func RedirectConfCheck(conf RedirectConfFile) error

func ReqSchemeSet

func ReqSchemeSet(req *bfe_basic.Request, scheme string)

ReqSchemeSet specify redirect url to absolute one with scheme user defined e.g., url scheme://host/path, usually scheme is https

func ReqUrlFromQuery

func ReqUrlFromQuery(req *bfe_basic.Request, key string)

ReqUrlFromQuery sets redirect url to value of given field in query e.g., url "http://service?url=(.*)" => "$1",

func ReqUrlPrefixAdd

func ReqUrlPrefixAdd(req *bfe_basic.Request, prefix string)

ReqUrlPrefixAdd specify redirect url by adding prefix to original uri(path+query) e.g., url "/(.*)" => "link$1",

func ReqUrlSet

func ReqUrlSet(req *bfe_basic.Request, url string)

ReqUrlSet sets redirect url

func RuleListCheck

func RuleListCheck(conf *RuleFileList) error

Types

type Action

type Action struct {
	Cmd    string   // command of action
	Params []string // params of action
}

type ActionFile

type ActionFile struct {
	Cmd    *string  // command of action
	Params []string // params of action
}

type ActionFileList

type ActionFileList []ActionFile

type ConfModRedirect

type ConfModRedirect struct {
	Basic struct {
		DataPath string // path of config data (redirect)
	}

	Log struct {
		OpenDebug bool
	}
}

func ConfLoad

func ConfLoad(filePath string, confRoot string) (*ConfModRedirect, error)

ConfLoad loads config from config file

func (*ConfModRedirect) Check

func (cfg *ConfModRedirect) Check(confRoot string) error

type ModuleRedirect

type ModuleRedirect struct {
	// contains filtered or unexported fields
}

func NewModuleRedirect

func NewModuleRedirect() *ModuleRedirect

func (*ModuleRedirect) Init

func (*ModuleRedirect) Name

func (m *ModuleRedirect) Name() string

type ProductRules

type ProductRules map[string]*RuleList // product => list of redirect rules

type ProductRulesFile

type ProductRulesFile map[string]*RuleFileList // product => list of redirect rules

type RedirectConfFile

type RedirectConfFile struct {
	Version *string // version of the config
	Config  *ProductRulesFile
}

type RedirectRule

type RedirectRule struct {
	Cond    condition.Condition // condition for redirect
	Actions []Action            // list of actions
	Status  int                 // redirect code
}

type RedirectRuleFile

type RedirectRuleFile struct {
	Cond    *string         // condition for redirect
	Actions *ActionFileList // list of actions
	Status  *int            // redirect code
}

type RedirectTable

type RedirectTable struct {
	// contains filtered or unexported fields
}

func NewRedirectTable

func NewRedirectTable() *RedirectTable

func (*RedirectTable) Search

func (t *RedirectTable) Search(product string) (*RuleList, bool)

func (*RedirectTable) Update

func (t *RedirectTable) Update(conf redirectConf)

type RuleFileList

type RuleFileList []RedirectRuleFile

type RuleList

type RuleList []RedirectRule

Jump to

Keyboard shortcuts

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