Make the debug handler an actual thing that can be set by users

This commit is contained in:
Asim
2016-01-06 19:24:54 +00:00
parent 66107fd304
commit 76918fc703
9 changed files with 137 additions and 91 deletions

View File

@@ -4,6 +4,7 @@ import (
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/server/debug"
"github.com/micro/go-micro/transport"
"golang.org/x/net/context"
@@ -23,6 +24,9 @@ type Options struct {
HdlrWrappers []HandlerWrapper
SubWrappers []SubscriberWrapper
// Debug Handler which can be set by a user
DebugHandler debug.DebugHandler
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
@@ -50,6 +54,10 @@ func newOptions(opt ...Option) Options {
opts.Transport = transport.DefaultTransport
}
if opts.DebugHandler == nil {
opts.DebugHandler = debug.DefaultDebugHandler
}
if len(opts.Address) == 0 {
opts.Address = DefaultAddress
}
@@ -132,6 +140,13 @@ func Transport(t transport.Transport) Option {
}
}
// DebugHandler for this server
func DebugHandler(d debug.DebugHandler) Option {
return func(o *Options) {
o.DebugHandler = d
}
}
// Metadata associated with the server
func Metadata(md map[string]string) Option {
return func(o *Options) {