go-proxy/options.go

36 lines
835 B
Go

package proxy
type Options struct {
Middlewares []Middleware
RequestTransformers []RequestTransformer
ResponseTransformers []ResponseTransformer
}
func defaultOptions() *Options {
return &Options{
Middlewares: make([]Middleware, 0),
RequestTransformers: make([]RequestTransformer, 0),
ResponseTransformers: make([]ResponseTransformer, 0),
}
}
type OptionFunc func(*Options)
func WithMiddlewares(middlewares ...Middleware) OptionFunc {
return func(o *Options) {
o.Middlewares = middlewares
}
}
func WithRequestTransformers(transformers ...RequestTransformer) OptionFunc {
return func(o *Options) {
o.RequestTransformers = transformers
}
}
func WithResponseTransformers(transformers ...ResponseTransformer) OptionFunc {
return func(o *Options) {
o.ResponseTransformers = transformers
}
}