feat: reusable rule engine to prevent memory reallocation
All checks were successful
Cadoles/bouncer/pipeline/pr-develop This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -1,20 +1,18 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"forge.cadoles.com/cadoles/bouncer/internal/rule"
|
||||
"github.com/expr-lang/expr"
|
||||
)
|
||||
|
||||
func WithRequestFuncs(r *http.Request) rule.OptionFunc {
|
||||
func WithRequestFuncs() rule.OptionFunc {
|
||||
return func(opts *rule.Options) {
|
||||
funcs := []expr.Option{
|
||||
setRequestURL(r),
|
||||
setRequestHeaderFunc(r),
|
||||
addRequestHeaderFunc(r),
|
||||
delRequestHeadersFunc(r),
|
||||
setRequestHostFunc(r),
|
||||
setRequestURLFunc(),
|
||||
setRequestHeaderFunc(),
|
||||
addRequestHeaderFunc(),
|
||||
delRequestHeadersFunc(),
|
||||
setRequestHostFunc(),
|
||||
}
|
||||
|
||||
if len(opts.Expr) == 0 {
|
||||
@ -25,12 +23,12 @@ func WithRequestFuncs(r *http.Request) rule.OptionFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func WithResponseFuncs(r *http.Response) rule.OptionFunc {
|
||||
func WithResponseFuncs() rule.OptionFunc {
|
||||
return func(opts *rule.Options) {
|
||||
funcs := []expr.Option{
|
||||
setResponseHeaderFunc(r),
|
||||
addResponseHeaderFunc(r),
|
||||
delResponseHeadersFunc(r),
|
||||
setResponseHeaderFunc(),
|
||||
addResponseHeaderFunc(),
|
||||
delResponseHeadersFunc(),
|
||||
}
|
||||
|
||||
if len(opts.Expr) == 0 {
|
||||
|
Reference in New Issue
Block a user