12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package api
- type Options struct {
- // URL前缀
- urlPrefix string
- // 端口
- port string
- // 日志跳过的打印路径
- logSkipPaths []string
- }
- func (options Options) GetPort() string {
- return options.port
- }
- func (options Options) GetUrlPrefix() string {
- return options.urlPrefix
- }
- type Option func(options *Options)
- // WithUrlPrefix 设置URL前缀
- func WithUrlPrefix(urlPrefix string) Option {
- return func(options *Options) {
- options.urlPrefix = urlPrefix
- }
- }
- // WithPort 设置端口
- func WithPort(port string) Option {
- return func(options *Options) {
- options.port = port
- }
- }
- // WithLogSkipPaths 设置日志跳过的打印路径
- func WithLogSkipPaths(logSkipPaths ...string) Option {
- return func(options *Options) {
- options.logSkipPaths = logSkipPaths
- }
- }
|