45 lines
884 B
Go
45 lines
884 B
Go
package http
|
|
|
|
import (
|
|
"forge.cadoles.com/cadoles/bouncer/internal/rule"
|
|
"github.com/expr-lang/expr"
|
|
)
|
|
|
|
func WithRequestFuncs() rule.OptionFunc {
|
|
return func(opts *rule.Options) {
|
|
funcs := []expr.Option{
|
|
setRequestURLFunc(),
|
|
setRequestHeaderFunc(),
|
|
addRequestHeaderFunc(),
|
|
delRequestHeadersFunc(),
|
|
setRequestHostFunc(),
|
|
getRequestCookieFunc(),
|
|
addRequestCookieFunc(),
|
|
}
|
|
|
|
if len(opts.Expr) == 0 {
|
|
opts.Expr = make([]expr.Option, 0)
|
|
}
|
|
|
|
opts.Expr = append(opts.Expr, funcs...)
|
|
}
|
|
}
|
|
|
|
func WithResponseFuncs() rule.OptionFunc {
|
|
return func(opts *rule.Options) {
|
|
funcs := []expr.Option{
|
|
setResponseHeaderFunc(),
|
|
addResponseHeaderFunc(),
|
|
delResponseHeadersFunc(),
|
|
addResponseCookieFunc(),
|
|
getResponseCookieFunc(),
|
|
}
|
|
|
|
if len(opts.Expr) == 0 {
|
|
opts.Expr = make([]expr.Option, 0)
|
|
}
|
|
|
|
opts.Expr = append(opts.Expr, funcs...)
|
|
}
|
|
}
|