本文整理汇总了Golang中github.com/polyverse-security/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.String方法的具体用法?Golang Context.String怎么用?Golang Context.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/polyverse-security/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: upsertHostAction
func (cmd *Command) upsertHostAction(c *cli.Context) {
host, err := engine.NewHost(c.String("name"), engine.HostSettings{})
if err != nil {
cmd.printError(err)
return
}
if c.String("cert") != "" || c.String("privateKey") != "" {
keyPair, err := readKeyPair(c.String("cert"), c.String("privateKey"))
if err != nil {
cmd.printError(fmt.Errorf("failed to read key pair: %s", err))
return
}
host.Settings.KeyPair = keyPair
}
host.Settings.OCSP = engine.OCSPSettings{
Enabled: c.Bool("ocsp"),
SkipSignatureCheck: c.Bool("ocspSkipCheck"),
Period: c.Duration("ocspPeriod").String(),
Responders: c.StringSlice("ocspResponder"),
}
if err := cmd.client.UpsertHost(*host); err != nil {
cmd.printError(err)
return
}
cmd.printOk("host added")
}
示例2: 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")
}
示例3: 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")
}
}
示例4: 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)
}
示例5: 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)
}
示例6: 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)
}
示例7: 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")
}
示例8: 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)
}
示例9: 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)
}
示例10: 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")})
}
示例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")
}
示例12: getFrontendSettings
func getFrontendSettings(c *cli.Context) (engine.HTTPFrontendSettings, error) {
s := engine.HTTPFrontendSettings{}
s.Limits.MaxMemBodyBytes = int64(c.Int("maxMemBodyKB") * 1024)
s.Limits.MaxBodyBytes = int64(c.Int("maxBodyKB") * 1024)
s.FailoverPredicate = c.String("failoverPredicate")
s.Hostname = c.String("forwardHost")
s.TrustForwardHeader = c.Bool("trustForwardHeader")
s.PassHostHeader = c.Bool("passHostHeader")
return s, nil
}
示例13: 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))
}
示例14: 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)
}
示例15: 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)
}