Codebase list golang-github-go-kit-kit / 7054e06
modify server side Serve methods to no longer generate a cancel context, and defer in it's calling. This is done so that there can be asynchronous calls that spawn off of the Server side that can inherit from the given context.Context. Theodore Schnepper 7 years ago
3 changed file(s) with 3 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
7373
7474 // ServeGRPC implements the Handler interface.
7575 func (s Server) ServeGRPC(grpcCtx context.Context, req interface{}) (context.Context, interface{}, error) {
76 ctx, cancel := context.WithCancel(s.ctx)
77 defer cancel()
76 ctx := s.ctx
7877
7978 // Retrieve gRPC metadata.
8079 md, ok := metadata.FromContext(grpcCtx)
7575
7676 // ServeHTTP implements http.Handler.
7777 func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
78 ctx, cancel := context.WithCancel(s.ctx)
79 defer cancel()
78 ctx := s.ctx
8079
8180 for _, f := range s.before {
8281 ctx = f(ctx, r)
5050
5151 // ServeHTTP implements http.Handler.
5252 func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
53 ctx, cancel := context.WithCancel(s.ctx)
54 defer cancel()
53 ctx := s.ctx
5554
5655 for _, f := range s.before {
5756 ctx = f(ctx, r)