2016-06-30 22:21:57 +03:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2018-03-03 15:28:44 +03:00
|
|
|
"context"
|
|
|
|
|
2018-12-19 12:53:34 +03:00
|
|
|
"github.com/micro/go-micro/broker"
|
2016-06-30 22:21:57 +03:00
|
|
|
"github.com/micro/go-micro/codec"
|
|
|
|
"github.com/micro/go-micro/registry"
|
|
|
|
"github.com/micro/go-micro/server"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newOptions(opt ...server.Option) server.Options {
|
|
|
|
opts := server.Options{
|
|
|
|
Codecs: make(map[string]codec.NewCodec),
|
|
|
|
Metadata: map[string]string{},
|
|
|
|
Context: context.Background(),
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, o := range opt {
|
|
|
|
o(&opts)
|
|
|
|
}
|
|
|
|
|
2018-12-19 12:53:34 +03:00
|
|
|
if opts.Broker == nil {
|
|
|
|
opts.Broker = broker.DefaultBroker
|
|
|
|
}
|
|
|
|
|
2016-06-30 22:21:57 +03:00
|
|
|
if opts.Registry == nil {
|
|
|
|
opts.Registry = registry.DefaultRegistry
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(opts.Address) == 0 {
|
|
|
|
opts.Address = server.DefaultAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(opts.Name) == 0 {
|
|
|
|
opts.Name = server.DefaultName
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(opts.Id) == 0 {
|
|
|
|
opts.Id = server.DefaultId
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(opts.Version) == 0 {
|
|
|
|
opts.Version = server.DefaultVersion
|
|
|
|
}
|
|
|
|
|
|
|
|
return opts
|
|
|
|
}
|