30 lines
771 B
Go
30 lines
771 B
Go
|
package proxy
|
||
|
|
||
|
type Options struct {
|
||
|
Middlewares []Middleware
|
||
|
ProxyRequestMiddlewares []ProxyRequestMiddleware
|
||
|
ProxyResponseMiddlewares []ProxyResponseMiddleware
|
||
|
}
|
||
|
|
||
|
func defaultOptions() *Options {
|
||
|
return &Options{
|
||
|
Middlewares: make([]Middleware, 0),
|
||
|
ProxyRequestMiddlewares: make([]ProxyRequestMiddleware, 0),
|
||
|
ProxyResponseMiddlewares: make([]ProxyResponseMiddleware, 0),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type OptionFunc func(*Options)
|
||
|
|
||
|
func WithProxyRequestMiddlewares(middlewares ...ProxyRequestMiddleware) OptionFunc {
|
||
|
return func(o *Options) {
|
||
|
o.ProxyRequestMiddlewares = middlewares
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func WithproxyResponseMiddlewares(middlewares ...ProxyResponseMiddleware) OptionFunc {
|
||
|
return func(o *Options) {
|
||
|
o.ProxyResponseMiddlewares = middlewares
|
||
|
}
|
||
|
}
|