1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

ensure the code does not panic

This commit is contained in:
Asim 2016-11-18 07:30:50 +00:00
parent 1688329049
commit f9709ffa6e

View File

@ -55,13 +55,12 @@ func newConsulRegistry(opts ...Option) Registry {
config := consul.DefaultConfig()
if options.Context != nil {
// Use the consul config passed in the options, if available
c := options.Context.Value("consul_config")
if c != nil {
config = c.(*consul.Config)
if c, ok := options.Context.Value("consul_config").(*consul.Config); ok {
config = c
}
t := options.Context.Value("consul_token")
if t != nil {
config.Token = t.(string)
if t, ok := options.Context.Value("consul_token").(string); ok {
config.Token = t
}
}