fix: initialize broker and subscribers
This commit is contained in:
		
							
								
								
									
										1
									
								
								http.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								http.go
									
									
									
									
									
								
							| @@ -238,6 +238,7 @@ func newServer(opts ...server.Option) server.Server { | |||||||
| 	return &httpServer{ | 	return &httpServer{ | ||||||
| 		opts: newOptions(opts...), | 		opts: newOptions(opts...), | ||||||
| 		exit: make(chan chan error), | 		exit: make(chan chan error), | ||||||
|  | 		subscribers: make(map[*httpSubscriber][]broker.Subscriber), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ package http | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
|  |  | ||||||
|  | 	"github.com/micro/go-micro/broker" | ||||||
| 	"github.com/micro/go-micro/codec" | 	"github.com/micro/go-micro/codec" | ||||||
| 	"github.com/micro/go-micro/registry" | 	"github.com/micro/go-micro/registry" | ||||||
| 	"github.com/micro/go-micro/server" | 	"github.com/micro/go-micro/server" | ||||||
| @@ -19,6 +20,10 @@ func newOptions(opt ...server.Option) server.Options { | |||||||
| 		o(&opts) | 		o(&opts) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if opts.Broker == nil { | ||||||
|  | 		opts.Broker = broker.DefaultBroker | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if opts.Registry == nil { | 	if opts.Registry == nil { | ||||||
| 		opts.Registry = registry.DefaultRegistry | 		opts.Registry = registry.DefaultRegistry | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user