mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
refactor(rules): introduce block DSL, phase-based execution, and flow validation
- 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
This commit is contained in:
@@ -1,21 +1,25 @@
|
||||
package rules
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
httputils "github.com/yusing/goutils/http"
|
||||
)
|
||||
|
||||
type (
|
||||
CheckFunc func(w http.ResponseWriter, r *http.Request) bool
|
||||
CheckFunc func(w *httputils.ResponseModifier, r *http.Request) bool
|
||||
Checker interface {
|
||||
Check(w http.ResponseWriter, r *http.Request) bool
|
||||
Check(w *httputils.ResponseModifier, r *http.Request) bool
|
||||
}
|
||||
CheckMatchSingle []Checker
|
||||
CheckMatchAll []Checker
|
||||
)
|
||||
|
||||
func (checker CheckFunc) Check(w http.ResponseWriter, r *http.Request) bool {
|
||||
func (checker CheckFunc) Check(w *httputils.ResponseModifier, r *http.Request) bool {
|
||||
return checker(w, r)
|
||||
}
|
||||
|
||||
func (checkers CheckMatchSingle) Check(w http.ResponseWriter, r *http.Request) bool {
|
||||
func (checkers CheckMatchSingle) Check(w *httputils.ResponseModifier, r *http.Request) bool {
|
||||
for _, check := range checkers {
|
||||
if check.Check(w, r) {
|
||||
return true
|
||||
@@ -24,7 +28,7 @@ func (checkers CheckMatchSingle) Check(w http.ResponseWriter, r *http.Request) b
|
||||
return false
|
||||
}
|
||||
|
||||
func (checkers CheckMatchAll) Check(w http.ResponseWriter, r *http.Request) bool {
|
||||
func (checkers CheckMatchAll) Check(w *httputils.ResponseModifier, r *http.Request) bool {
|
||||
for _, check := range checkers {
|
||||
if !check.Check(w, r) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user