From 7968395d5152589d56fda251b90ce79444ff3d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E6=96=B0=E9=A3=9E?= Date: Wed, 19 Dec 2018 17:53:34 +0800 Subject: [PATCH] fix: initialize broker and subscribers --- http.go | 1 + options.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/http.go b/http.go index 4d6fb00..3469c4d 100644 --- a/http.go +++ b/http.go @@ -238,6 +238,7 @@ func newServer(opts ...server.Option) server.Server { return &httpServer{ opts: newOptions(opts...), exit: make(chan chan error), + subscribers: make(map[*httpSubscriber][]broker.Subscriber), } } diff --git a/options.go b/options.go index ea065ca..b3cc810 100644 --- a/options.go +++ b/options.go @@ -3,6 +3,7 @@ package http import ( "context" + "github.com/micro/go-micro/broker" "github.com/micro/go-micro/codec" "github.com/micro/go-micro/registry" "github.com/micro/go-micro/server" @@ -19,6 +20,10 @@ func newOptions(opt ...server.Option) server.Options { o(&opts) } + if opts.Broker == nil { + opts.Broker = broker.DefaultBroker + } + if opts.Registry == nil { opts.Registry = registry.DefaultRegistry }