2024-06-25 14:03:49 +02:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/rule"
|
|
|
|
"github.com/expr-lang/expr"
|
|
|
|
)
|
|
|
|
|
2024-09-24 15:46:42 +02:00
|
|
|
func WithRequestFuncs() rule.OptionFunc {
|
2024-06-25 14:03:49 +02:00
|
|
|
return func(opts *rule.Options) {
|
|
|
|
funcs := []expr.Option{
|
2024-09-24 15:46:42 +02:00
|
|
|
setRequestURLFunc(),
|
|
|
|
setRequestHeaderFunc(),
|
|
|
|
addRequestHeaderFunc(),
|
|
|
|
delRequestHeadersFunc(),
|
|
|
|
setRequestHostFunc(),
|
2024-09-25 15:50:13 +02:00
|
|
|
getRequestCookieFunc(),
|
|
|
|
addRequestCookieFunc(),
|
2024-06-25 14:03:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(opts.Expr) == 0 {
|
|
|
|
opts.Expr = make([]expr.Option, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
opts.Expr = append(opts.Expr, funcs...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-24 15:46:42 +02:00
|
|
|
func WithResponseFuncs() rule.OptionFunc {
|
2024-06-25 14:03:49 +02:00
|
|
|
return func(opts *rule.Options) {
|
|
|
|
funcs := []expr.Option{
|
2024-09-24 15:46:42 +02:00
|
|
|
setResponseHeaderFunc(),
|
|
|
|
addResponseHeaderFunc(),
|
|
|
|
delResponseHeadersFunc(),
|
2024-09-25 15:50:13 +02:00
|
|
|
addResponseCookieFunc(),
|
|
|
|
getResponseCookieFunc(),
|
2024-06-25 14:03:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(opts.Expr) == 0 {
|
|
|
|
opts.Expr = make([]expr.Option, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
opts.Expr = append(opts.Expr, funcs...)
|
|
|
|
}
|
|
|
|
}
|