當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cli.Context類代碼示例

本文整理匯總了Golang中github.com/polyverse-security/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context的典型用法代碼示例。如果您正苦於以下問題:Golang Context類的具體用法?Golang Context怎麽用?Golang Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: deleteHostAction

func (cmd *Command) deleteHostAction(c *cli.Context) {
	if err := cmd.client.DeleteHost(engine.HostKey{Name: c.String("name")}); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("host deleted")
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:7,代碼來源:host.go

示例2: deleteBackendAction

func (cmd *Command) deleteBackendAction(c *cli.Context) {
	if err := cmd.client.DeleteBackend(engine.BackendKey{Id: c.String("id")}); err != nil {
		cmd.printError(err)
	} else {
		cmd.printOk("backend deleted")
	}
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:7,代碼來源:backend.go

示例3: printHostAction

func (cmd *Command) printHostAction(c *cli.Context) {
	host, err := cmd.client.GetHost(engine.HostKey{Name: c.String("name")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printHost(host)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:8,代碼來源:host.go

示例4: printListenerAction

func (cmd *Command) printListenerAction(c *cli.Context) {
	l, err := cmd.client.GetListener(engine.ListenerKey{Id: c.String("id")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printListener(l)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:8,代碼來源:listener.go

示例5: printServersAction

func (cmd *Command) printServersAction(c *cli.Context) {
	srvs, err := cmd.client.GetServers(engine.BackendKey{Id: c.String("backend")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printServers(srvs)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:8,代碼來源:server.go

示例6: deleteFrontendAction

func (cmd *Command) deleteFrontendAction(c *cli.Context) {
	err := cmd.client.DeleteFrontend(engine.FrontendKey{Id: c.String("id")})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("frontend deleted")
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:8,代碼來源:frontend.go

示例7: printServerAction

func (cmd *Command) printServerAction(c *cli.Context) {
	s, err := cmd.client.GetServer(engine.ServerKey{Id: c.String("id"), BackendKey: engine.BackendKey{Id: c.String("backend")}})
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printServer(s)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:8,代碼來源:server.go

示例8: deleteServerAction

func (cmd *Command) deleteServerAction(c *cli.Context) {
	sk := engine.ServerKey{BackendKey: engine.BackendKey{Id: c.String("backend")}, Id: c.String("id")}
	if err := cmd.client.DeleteServer(sk); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("Server %v deleted", sk.Id)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:8,代碼來源:server.go

示例9: FromCli

// FromCli constructs a middleware instance from the command line parameters.
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return FromOther(
		RateLimit{
			PeriodSeconds: int64(c.Int("period")),
			Requests:      int64(c.Int("requests")),
			Burst:         int64(c.Int("burst")),
			Variable:      c.String("var"),
			RateVar:       c.String("rateVar")})
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:10,代碼來源:ratelimit.go

示例10: initBundle

func initBundle(c *cli.Context) {
	b, err := NewBundler(c.StringSlice("middleware"))
	if err != nil {
		log.Errorf("Failed to bundle middlewares: %s", err)
		return
	}
	if err := b.bundle(); err != nil {
		log.Errorf("Failed to bundle middlewares: %s", err)
	} else {
		log.Infof("SUCCESS: bundle vulcand and vctl completed")
	}
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:12,代碼來源:main.go

示例11: updateLogSeverityAction

func (cmd *Command) updateLogSeverityAction(c *cli.Context) {
	sev, err := log.SeverityFromString(c.String("severity"))
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpdateLogSeverity(sev); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("log severity updated")
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:12,代碼來源:log.go

示例12: upsertBackendAction

func (cmd *Command) upsertBackendAction(c *cli.Context) {
	settings, err := getBackendSettings(c)
	if err != nil {
		cmd.printError(err)
		return
	}
	b, err := engine.NewHTTPBackend(c.String("id"), settings)
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printResult("%s upserted", b, cmd.client.UpsertBackend(*b))
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:13,代碼來源:backend.go

示例13: printBackendAction

func (cmd *Command) printBackendAction(c *cli.Context) {
	bk := engine.BackendKey{Id: c.String("id")}
	b, err := cmd.client.GetBackend(bk)
	if err != nil {
		cmd.printError(err)
		return
	}
	srvs, err := cmd.client.GetServers(bk)
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printBackend(b, srvs)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:14,代碼來源:backend.go

示例14: printFrontendAction

func (cmd *Command) printFrontendAction(c *cli.Context) {
	fk := engine.FrontendKey{Id: c.String("id")}
	frontend, err := cmd.client.GetFrontend(fk)
	if err != nil {
		cmd.printError(err)
		return
	}

	ms, err := cmd.client.GetMiddlewares(fk)
	if err != nil {
		cmd.printError(err)
		return
	}
	cmd.printFrontend(frontend, ms)
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:15,代碼來源:frontend.go

示例15: upsertServerAction

func (cmd *Command) upsertServerAction(c *cli.Context) {
	s, err := engine.NewServer(c.String("id"), c.String("url"))
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpsertServer(engine.BackendKey{Id: c.String("backend")}, *s, c.Duration("ttl")); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("server upserted")
}
開發者ID:polyverse-security,項目名稱:vulcand,代碼行數:12,代碼來源:server.go


注:本文中的github.com/polyverse-security/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。