redirect

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRedirectMessageHeader = "X-Redirect-Message"
)

DefaultRedirectMessageHeader Default HTTP response header constant definition for redirect message.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emits

type Emits map[string]*TriggerEvent

Emits is a mapping configuration used to trigger events.

func (Emits) SetTriggerEvent

func (emit Emits) SetTriggerEvent(key string, event *TriggerEvent) Emits

SetTriggerEvent If the triggering event already exists, it is overwritten.

func (Emits) TriggerEvent

func (emit Emits) TriggerEvent(key string) *TriggerEvent

TriggerEvent Get the trigger event for key.

func (Emits) URIIsRedirect

func (emit Emits) URIIsRedirect(uri string) bool

type Ignore

type Ignore map[string]bool

Ignore will skip the redirect detection without triggering redirection events.

func (Ignore) URIIsIgnore

func (ignore Ignore) URIIsIgnore(uri string) bool

URIIsIgnore Checks whether the URI is set to ignore.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option design modern impl.

func WithRedirectMessageHeader

func WithRedirectMessageHeader(header string) Option

WithRedirectMessageHeader Specify redirect message HTTP response header.

func WithSetIgnoreURI

func WithSetIgnoreURI(uri string, ignore bool) Option

WithSetIgnoreURI Specify redirecter ignore HTTP request.

func WithWatcherOfRedisClient

func WithWatcherOfRedisClient(client *redis.Client) Option

WithWatcherOfRedisClient Specify redisclient config when watcher is redisclient.

type Redirect

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

func NewRedirect

func NewRedirect(emits Emits, watcher Watcher, ops ...Option) *Redirect

func (*Redirect) Handler

func (redirect *Redirect) Handler() gin.HandlerFunc

type Redirecter

type Redirecter interface {
	Handler() gin.HandlerFunc
}

type TriggerEvent

type TriggerEvent struct {
	StatusCode            int    // Http status code.
	RedirectURI           string // redirect uri.
	RedirectHeaderMessage string // Redirect header message,
}

TriggerEvent trigger redirection event.

type Watcher

type Watcher string

Watcher watcher type definition.

const (
	WatcherOfFile  Watcher = "file"
	WatcherOfRedis Watcher = "redis"
)

WatchType current support watch type.

Jump to

Keyboard shortcuts

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