add server publication wrapper example

This commit is contained in:
Asim 2015-12-02 20:00:06 +00:00
parent eef155490e
commit ef8303f11f

View File

@ -18,12 +18,22 @@ func logWrapper(fn server.HandlerFunc) server.HandlerFunc {
} }
} }
func logSubWrapper(fn server.SubscriberFunc) server.SubscriberFunc {
return func(ctx context.Context, req interface{}) error {
log.Infof("[Log Sub Wrapper] Before serving publication")
err := fn(ctx, req)
log.Infof("[Log Sub Wrapper] After serving publication")
return err
}
}
func main() { func main() {
// optionally setup command line usage // optionally setup command line usage
cmd.Init() cmd.Init()
server.DefaultServer = server.NewServer( server.DefaultServer = server.NewServer(
server.WrapHandler(logWrapper), server.WrapHandler(logWrapper),
server.WrapSubscriber(logSubWrapper),
) )
// Initialise Server // Initialise Server