feat: new action process

This commit is contained in:
Roi Feng
2025-02-13 22:20:53 -05:00
parent c7e9a69f8b
commit aea36d463b
7 changed files with 123 additions and 74 deletions

View File

@ -1,26 +1,35 @@
package action
type Action int
type checkState int
const (
Undecided Action = iota // 0Undecided
Allow // 1Pass
Block // 2Deny
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
}