action

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// connection actions
	ActionClose  = "CLOSE"  // close, close the connection directly
	ActionPass   = "PASS"   // pass, do nothing
	ActionFinish = "FINISH" // finish, close connection after reply

	// header actions
	ActionReqHeaderAdd = "REQ_HEADER_ADD" // add request header
	ActionReqHeaderSet = "REQ_HEADER_SET" // set request header
	ActionReqHeaderDel = "REQ_HEADER_DEL" // del request header

	// host actions
	ActionHostSetFromPathPrefix = "HOST_SET_FROM_PATH_PREFIX" // set host from path prefix
	ActionHostSet               = "HOST_SET"                  // set host
	ActionHostSuffixReplace     = "HOST_SUFFIX_REPLACE"       // set host replaced suffx

	// path actions
	ActionPathSet        = "PATH_SET"         // set path
	ActionPathPrefixAdd  = "PATH_PREFIX_ADD"  // add path prefix
	ActionPathPrefixTrim = "PATH_PREFIX_TRIM" // trim path prefix

	// query actions
	ActionQueryAdd          = "QUERY_ADD"            // add query
	ActionQueryDel          = "QUERY_DEL"            // del query
	ActionQueryRename       = "QUERY_RENAME"         // rename query
	ActionQueryDelAllExcept = "QUERY_DEL_ALL_EXCEPT" // del query except given query key
)
View Source
const HeaderPrefix = "X-BFE-"

Variables

This section is empty.

Functions

func ActionFileCheck

func ActionFileCheck(conf ActionFile) error

func ReqHostSet

func ReqHostSet(req *bfe_basic.Request, hostname string)

ReqHostSet sets hostname to request.

func ReqHostSetFromFirstPathSegment

func ReqHostSetFromFirstPathSegment(req *bfe_basic.Request)

ReqHostSetFromFirstPathSegment set hostname from first path segment.

example: if uri path pattern is /x.baidu.com/xxxx,

set host x.baidu.com
set uri path  /xxx

if do not match this pattern, do noting

func ReqHostSuffixReplace

func ReqHostSuffixReplace(req *bfe_basic.Request, originSuffix, newSuffix string)

ReqHostSuffixReplace replaces suffix of hostname.

func ReqPathPrefixAdd

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

ReqPathPrefixAdd adds prefix to path. e.g., path "/(.*)" => "/link?$1",

func ReqPathPrefixTrim

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

ReqPathPrefixTrim trims prefix of path e.g., path "/service/shortcut/(.*)" => "/$1",

func ReqPathSet

func ReqPathSet(req *bfe_basic.Request, path string)

ReqPathSet sets path to request.

func ReqQueryAdd

func ReqQueryAdd(req *bfe_basic.Request, params []string)

ReqQueryAdd adds some number of (key, value) to query.

func ReqQueryDel

func ReqQueryDel(req *bfe_basic.Request, keys []string)

ReqQueryDel deletes some keys from query

func ReqQueryDelAllExcept

func ReqQueryDelAllExcept(req *bfe_basic.Request, keys []string)

ReqQueryDelAllExcept deletes all keys from query, except some keys

func ReqQueryRename

func ReqQueryRename(req *bfe_basic.Request, oldName string, newName string)

ReqQueryRename renames query key from old name to new name.

Types

type Action

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

func (*Action) Check

func (ac *Action) Check(allowActions map[string]bool) error

func (*Action) Do

func (ac *Action) Do(req *bfe_basic.Request) error

Do process action for request

func (*Action) UnmarshalJSON

func (ac *Action) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes given data in json format

type ActionFile

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

Jump to

Keyboard shortcuts

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