Update wrapper and examples

This commit is contained in:
Asim
2015-12-02 11:54:36 +00:00
parent c5a08d3159
commit b1511ed813
7 changed files with 130 additions and 86 deletions

View File

@@ -6,15 +6,25 @@ import (
"github.com/micro/go-micro/examples/server/handler"
"github.com/micro/go-micro/examples/server/subscriber"
"github.com/micro/go-micro/server"
"golang.org/x/net/context"
)
func logWrapper(fn server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req interface{}, rsp interface{}) error {
log.Infof("[Log Wrapper] Before serving request")
err := fn(ctx, req, rsp)
log.Infof("[Log Wrapper] After serving request")
return err
}
}
func main() {
// optionally setup command line usage
cmd.Init()
// server.DefaultServer = server.NewServer(
// server.Codec("application/bson", bson.Codec),
// )
server.DefaultServer = server.NewServer(
server.WrapHandler(logWrapper),
)
// Initialise Server
server.Init(