func (s *server) handleWithMiddleware( ctx types.Context, route types.Route) types.APIFunc { /*if route.GetMethod() == "HEAD" { return route.GetHandler() }*/ handler := route.GetHandler() middlewaresForRouteName, ok := s.routeHandlers[route.GetName()] if !ok { ctx.Warn("no middlewares for route") } else { for h := range reverse(middlewaresForRouteName) { handler = h.Handler(handler) ctx.WithField( "middleware", h.Name()).Debug("added route middleware") } } // add the global handlers for h := range reverse(s.globalHandlers) { handler = h.Handler(handler) ctx.WithField( "middleware", h.Name()).Debug("added global middleware") } return handler }
func (c *client) dial(ctx types.Context) error { ctx.WithField("path", lsxMutex).Info("lsx lock file path") svcInfos, err := c.Services(ctx) if err != nil { return err } // controller clients do not have any additional dialer logic if c.isController() { return nil } store := utils.NewStore() c.ctx = c.ctx.WithValue(context.ServerKey, c.ServerName()) if !c.config.GetBool(types.ConfigExecutorNoDownload) { ctx.Info("initializing executors cache") if _, err := c.Executors(ctx); err != nil { return err } if err := c.updateExecutor(ctx); err != nil { return err } } for service, _ := range svcInfos { ctx := c.ctx.WithValue(context.ServiceKey, service) ctx.Info("initializing supported cache") supported, err := c.Supported(ctx, store) if err != nil { return goof.WithError("error initializing supported cache", err) } if !supported { ctx.Warn("executor not supported") continue } ctx.Info("initializing instance ID cache") if _, err := c.InstanceID(ctx, store); err != nil { if err == types.ErrNotImplemented { ctx.WithError(err).Warn("cannot get instance ID") continue } return goof.WithError("error initializing instance ID cache", err) } } return nil }