rewrite api package

This commit is contained in:
Asim Aslam
2020-10-17 15:33:56 +01:00
parent f2728a7fee
commit 975da990a9
13 changed files with 44 additions and 164 deletions

62
api/options.go Normal file
View File

@@ -0,0 +1,62 @@
package api
import (
"crypto/tls"
"github.com/micro/go-micro/v3/api/acme"
"github.com/micro/go-micro/v3/api/resolver"
)
type Options struct {
Address string
EnableACME bool
ACMEProvider acme.Provider
EnableTLS bool
ACMEHosts []string
TLSConfig *tls.Config
Resolver resolver.Resolver
}
type Option func(o *Options)
func Address(a string) Option {
return func(o *Options) {
o.Address = a
}
}
func EnableACME(b bool) Option {
return func(o *Options) {
o.EnableACME = b
}
}
func ACMEHosts(hosts ...string) Option {
return func(o *Options) {
o.ACMEHosts = hosts
}
}
func ACMEProvider(p acme.Provider) Option {
return func(o *Options) {
o.ACMEProvider = p
}
}
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
}
}
func Resolver(r resolver.Resolver) Option {
return func(o *Options) {
o.Resolver = r
}
}