mirror of
https://github.com/Rayzggz/server_torii.git
synced 2025-06-23 15:31:31 +08:00
feat: new action process
This commit is contained in:
@ -1,26 +1,35 @@
|
||||
package action
|
||||
|
||||
type Action int
|
||||
type checkState int
|
||||
|
||||
const (
|
||||
Undecided Action = iota // 0:Undecided
|
||||
Allow // 1:Pass
|
||||
Block // 2:Deny
|
||||
Continue checkState = iota
|
||||
Done
|
||||
Jump
|
||||
)
|
||||
|
||||
// Decision saves the result of the decision
|
||||
type Decision struct {
|
||||
result Action
|
||||
HTTPCode string
|
||||
State checkState
|
||||
JumpIndex int
|
||||
}
|
||||
|
||||
func NewDecision() *Decision {
|
||||
return &Decision{result: Undecided}
|
||||
return &Decision{HTTPCode: "200", State: Continue, JumpIndex: -1}
|
||||
}
|
||||
|
||||
func (d *Decision) Get() Action {
|
||||
return d.result
|
||||
func (d *Decision) Set(state checkState) {
|
||||
d.State = state
|
||||
}
|
||||
|
||||
func (d *Decision) Set(new Action) {
|
||||
d.result = new
|
||||
func (d *Decision) SetCode(state checkState, httpCode string) {
|
||||
d.State = state
|
||||
d.HTTPCode = httpCode
|
||||
}
|
||||
|
||||
func (d *Decision) SetJump(state checkState, httpCode string, jumpIndex int) {
|
||||
d.State = state
|
||||
d.HTTPCode = httpCode
|
||||
d.JumpIndex = jumpIndex
|
||||
}
|
||||
|
Reference in New Issue
Block a user