ensure the code does not panic
This commit is contained in:
parent
1688329049
commit
f9709ffa6e
@ -55,13 +55,12 @@ func newConsulRegistry(opts ...Option) Registry {
|
|||||||
config := consul.DefaultConfig()
|
config := consul.DefaultConfig()
|
||||||
if options.Context != nil {
|
if options.Context != nil {
|
||||||
// Use the consul config passed in the options, if available
|
// Use the consul config passed in the options, if available
|
||||||
c := options.Context.Value("consul_config")
|
if c, ok := options.Context.Value("consul_config").(*consul.Config); ok {
|
||||||
if c != nil {
|
config = c
|
||||||
config = c.(*consul.Config)
|
|
||||||
}
|
}
|
||||||
t := options.Context.Value("consul_token")
|
|
||||||
if t != nil {
|
if t, ok := options.Context.Value("consul_token").(string); ok {
|
||||||
config.Token = t.(string)
|
config.Token = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user