mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-23 09:31:02 +01:00
- add block syntax parser/scanner with nested @blocks and elif/else support - restructure rule execution into explicit pre/post phases with phase flags - classify commands by phase and termination behavior - enforce flow semantics (default rule handling, dead-rule detection) - expand HTTP flow coverage with block + YAML parity tests and benches - refresh rules README/spec and update playground/docs integration
39 lines
798 B
Go
39 lines
798 B
Go
package rules
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httputils "github.com/yusing/goutils/http"
|
|
)
|
|
|
|
type (
|
|
CheckFunc func(w *httputils.ResponseModifier, r *http.Request) bool
|
|
Checker interface {
|
|
Check(w *httputils.ResponseModifier, r *http.Request) bool
|
|
}
|
|
CheckMatchSingle []Checker
|
|
CheckMatchAll []Checker
|
|
)
|
|
|
|
func (checker CheckFunc) Check(w *httputils.ResponseModifier, r *http.Request) bool {
|
|
return checker(w, r)
|
|
}
|
|
|
|
func (checkers CheckMatchSingle) Check(w *httputils.ResponseModifier, r *http.Request) bool {
|
|
for _, check := range checkers {
|
|
if check.Check(w, r) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (checkers CheckMatchAll) Check(w *httputils.ResponseModifier, r *http.Request) bool {
|
|
for _, check := range checkers {
|
|
if !check.Check(w, r) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|