Documentation
¶
Index ¶
Constants ¶
View Source
const ( ActionLog = "log" // allow and log ActionBlock = "block" // block ActionCaptcha = "captcha" // block and show captcha ActionAllow = "allow" // allow )
View Source
const (
CaptchaSeconds = 600 // 10 minutes
)
Variables ¶
View Source
var AllActions = []*ActionDefinition{ { Name: "阻止", Code: ActionBlock, Instance: new(BlockAction), }, { Name: "允许通过", Code: ActionAllow, Instance: new(AllowAction), }, { Name: "允许并记录日志", Code: ActionLog, Instance: new(LogAction), }, { Name: "Captcha验证码", Code: ActionCaptcha, Instance: new(CaptchaAction), }, }
Functions ¶
func FindActionName ¶
func FindActionName(action ActionString) string
Types ¶
type ActionDefinition ¶
type ActionDefinition struct {
Name string
Code ActionString
Description string
Instance ActionInterface
}
action definition
type ActionInterface ¶
type ActionInterface interface {
Perform(request *http.Request, 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(request *http.Request, 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(request *http.Request, writer http.ResponseWriter) (allow bool)
type CaptchaAction ¶ added in v0.1.9
type CaptchaAction struct {
}
func (*CaptchaAction) Perform ¶ added in v0.1.9
func (this *CaptchaAction) Perform(request *http.Request, writer http.ResponseWriter) (allow bool)
Click to show internal directories.
Click to hide internal directories.