refactor(http,rules): move SharedData and ResponseModifier to httputils

- implemented dependency injection for rule auth handler
This commit is contained in:
yusing
2025-12-05 16:06:36 +08:00
parent 8687a57b6c
commit 25ee8041da
19 changed files with 106 additions and 452 deletions

View File

@@ -5,6 +5,8 @@ import (
"net/http"
"strings"
"unsafe"
httputils "github.com/yusing/goutils/http"
)
type templateString struct {
@@ -27,7 +29,7 @@ func (tmpl *templateString) ExpandVars(w http.ResponseWriter, req *http.Request,
return err
}
return ExpandVars(GetInitResponseModifier(w), req, tmpl.string, dstW)
return ExpandVars(httputils.GetInitResponseModifier(w), req, tmpl.string, dstW)
}
func (tmpl *templateString) ExpandVarsToString(w http.ResponseWriter, req *http.Request) (string, error) {
@@ -36,7 +38,7 @@ func (tmpl *templateString) ExpandVarsToString(w http.ResponseWriter, req *http.
}
var buf strings.Builder
err := ExpandVars(GetInitResponseModifier(w), req, tmpl.string, &buf)
err := ExpandVars(httputils.GetInitResponseModifier(w), req, tmpl.string, &buf)
if err != nil {
return "", err
}