micro/api/server/options.go

55 lines
816 B
Go
Raw Normal View History

2019-06-03 20:44:43 +03:00
package server
import (
"crypto/tls"
"github.com/micro/go-micro/v2/api/server/acme"
2019-06-03 20:44:43 +03:00
)
type Option func(o *Options)
type Options struct {
EnableACME bool
2020-03-04 14:40:53 +03:00
EnableCORS bool
ACMEProvider acme.Provider
EnableTLS bool
ACMEHosts []string
TLSConfig *tls.Config
}
2020-03-04 14:40:53 +03:00
func EnableCORS(b bool) Option {
return func(o *Options) {
o.EnableCORS = b
}
}
func EnableACME(b bool) Option {
return func(o *Options) {
o.EnableACME = b
}
2019-06-03 20:44:43 +03:00
}
func ACMEHosts(hosts ...string) Option {
return func(o *Options) {
o.ACMEHosts = hosts
}
}
func ACMEProvider(p acme.Provider) Option {
2019-06-03 20:44:43 +03:00
return func(o *Options) {
o.ACMEProvider = p
2019-06-03 20:44:43 +03:00
}
}
func EnableTLS(b bool) Option {
return func(o *Options) {
o.EnableTLS = b
}
}
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = t
}
}