refactor: refine byte pools usage and fix memory leak in rules

This commit is contained in:
yusing
2025-10-15 23:53:26 +08:00
parent 2b4c39a79e
commit 44536139c1
7 changed files with 73 additions and 42 deletions

View File

@@ -8,6 +8,7 @@ import (
type templateOrStr interface {
Execute(w io.Writer, data any) error
Len() int
}
type strTemplate string
@@ -23,6 +24,10 @@ func (t strTemplate) Execute(w io.Writer, _ any) error {
return nil
}
func (t strTemplate) Len() int {
return len(t)
}
type keyValueTemplate = Tuple[string, templateOrStr]
func executeRequestTemplateString(tmpl templateOrStr, r *http.Request) (string, error) {