func resourceServerMiddleware(c martini.Context, p *ct.Provider, dc resource.DiscoverdClient, r ResponseHelper) { server, err := resource.NewServerWithDiscoverd(p.URL, dc) if err != nil { r.Error(err) return } c.Map(server) c.Next() server.Close() }
func connectHostMiddleware(c martini.Context, params martini.Params, cl clusterClient, r ResponseHelper) { hostID, jobID := parseJobID(params["jobs_id"]) if hostID == "" { log.Printf("Unable to parse hostID from %q", params["jobs_id"]) r.Error(ErrNotFound) return } params["jobs_id"] = jobID client, err := cl.DialHost(hostID) if err != nil { r.Error(err) return } c.MapTo(client, (*cluster.Host)(nil)) c.Next() client.Close() }