actions

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ActionLog     = "log"     // allow and log
	ActionBlock   = "block"   // block
	ActionCaptcha = "captcha" // block and show captcha // TODO
	ActionAllow   = "allow"   // allow
)

Variables

View Source
var AllActions = []*ActionDefinition{
	{
		Name:     "阻止",
		Code:     ActionBlock,
		Instance: new(BlockAction),
	},
	{
		Name:     "允许通过",
		Code:     ActionAllow,
		Instance: new(AllowAction),
	},
	{
		Name:     "允许并记录日志",
		Code:     ActionLog,
		Instance: new(LogAction),
	},
}

Functions

func FindActionName

func FindActionName(action ActionString) string

Types

type Action

type Action struct {
}

type ActionDefinition

type ActionDefinition struct {
	Name        string
	Code        ActionString
	Description string
	Instance    ActionInterface
}

type ActionInterface

type ActionInterface interface {
	Perform(writer http.ResponseWriter) (allow bool)
}

func FindActionInstance

func FindActionInstance(action ActionString) ActionInterface

type ActionString

type ActionString = string

type AllowAction

type AllowAction struct {
}

func (*AllowAction) Perform

func (this *AllowAction) Perform(writer http.ResponseWriter) (allow bool)

type BlockAction

type BlockAction struct {
	StatusCode int    `yaml:"statusCode" json:"statusCode"`
	Body       string `yaml:"body" json:"body"` // supports HTML
	URL        string `yaml:"url" json:"url"`
}

func (*BlockAction) Perform

func (this *BlockAction) Perform(writer http.ResponseWriter) (allow bool)

type LogAction

type LogAction struct {
}

func (*LogAction) Perform

func (this *LogAction) Perform(writer http.ResponseWriter) (allow bool)

Jump to

Keyboard shortcuts

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