本文整理汇总了Golang中github.com/convox/kernel/Godeps/_workspace/src/github.com/gorilla/mux.Vars函数的典型用法代码示例。如果您正苦于以下问题:Golang Vars函数的具体用法?Golang Vars怎么用?Golang Vars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ServiceStream
func ServiceStream(rw http.ResponseWriter, r *http.Request) {
log := servicesLogger("stream").Start()
service, err := models.GetServiceFromName(mux.Vars(r)["service"])
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
logs := make(chan []byte)
done := make(chan bool)
service.SubscribeLogs(logs, done)
ws, err := upgrader.Upgrade(rw, r, nil)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=upgrade service=%q", service.Name)
defer ws.Close()
for data := range logs {
ws.WriteMessage(websocket.TextMessage, data)
}
log.Success("step=ended service=%q", service.Name)
}
开发者ID:nguyendangminh,项目名称:kernel,代码行数:34,代码来源:services.go
示例2: AppEnvironment
func AppEnvironment(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("environment").Start()
app := mux.Vars(r)["app"]
env, err := models.GetEnvironment(app)
if awsError(err) == "ValidationError" {
RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
return
}
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
params := map[string]interface{}{
"App": app,
"Environment": env,
}
switch r.Header.Get("Content-Type") {
case "application/json":
RenderJson(rw, params["Environment"])
default:
RenderPartial(rw, "app", "environment", params)
}
}
开发者ID:oren,项目名称:kernel,代码行数:30,代码来源:apps.go
示例3: ServiceDelete
func ServiceDelete(rw http.ResponseWriter, r *http.Request) {
log := servicesLogger("delete").Start()
vars := mux.Vars(r)
name := vars["service"]
service, err := models.GetServiceFromName(name)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=services.get service=%q", service.Name)
err = service.Delete()
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=service.delete service=%q", service.Name)
RenderText(rw, "ok")
}
开发者ID:nguyendangminh,项目名称:kernel,代码行数:28,代码来源:services.go
示例4: AppLogs
func AppLogs(rw http.ResponseWriter, r *http.Request) {
// log := appsLogger("logs").Start()
app := mux.Vars(r)["app"]
RenderPartial(rw, "app", "logs", app)
}
开发者ID:oren,项目名称:kernel,代码行数:7,代码来源:apps.go
示例5: ReleasePromote
func ReleasePromote(rw http.ResponseWriter, r *http.Request) {
log := releasesLogger("promote").Start()
vars := mux.Vars(r)
app := vars["app"]
release := vars["release"]
rel, err := models.GetRelease(app, release)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
err = rel.Promote()
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=release.promote app=%q", app)
RenderText(rw, "ok")
}
开发者ID:nguyendangminh,项目名称:kernel,代码行数:27,代码来源:releases.go
示例6: AppShow
func AppShow(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("show").Start()
app := mux.Vars(r)["app"]
a, err := models.GetApp(app)
if awsError(err) == "ValidationError" {
RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
return
}
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
switch r.Header.Get("Content-Type") {
case "application/json":
RenderJson(rw, a)
default:
RenderTemplate(rw, "app", a)
}
}
开发者ID:oren,项目名称:kernel,代码行数:25,代码来源:apps.go
示例7: ProcessRunAttached
func ProcessRunAttached(ws *websocket.Conn) {
defer ws.Close()
log := processesLogger("run.attached").Start()
vars := mux.Vars(ws.Request())
app := vars["app"]
process := vars["process"]
command := ws.Request().Header.Get("Command")
ps, err := models.GetProcess(app, process)
if err != nil {
helpers.Error(log, err)
ws.Write([]byte(fmt.Sprintf("error: %s\n", err)))
return
}
log.Success("step=upgrade app=%q", ps.App)
defer ws.Close()
err = ps.RunAttached(command, ws)
if err != nil {
helpers.Error(log, err)
ws.Write([]byte(fmt.Sprintf("error: %s\n", err)))
return
}
log.Success("step=ended app=%q", ps.App)
}
开发者ID:2opremio,项目名称:kernel,代码行数:32,代码来源:processes.go
示例8: EnvironmentDelete
func EnvironmentDelete(rw http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
app := vars["app"]
name := vars["name"]
env, err := models.GetEnvironment(app)
if awsError(err) == "ValidationError" {
RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
return
}
if err != nil {
helpers.Error(nil, err)
RenderError(rw, err)
return
}
delete(env, name)
err = models.PutEnvironment(app, env)
if err != nil {
helpers.Error(nil, err)
RenderError(rw, err)
return
}
RenderText(rw, "ok")
}
开发者ID:nguyendangminh,项目名称:kernel,代码行数:31,代码来源:environment.go
示例9: EnvironmentCreate
func EnvironmentCreate(rw http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
app := vars["app"]
name := vars["name"]
value := GetForm(r, "value")
env, err := models.GetEnvironment(app)
if err != nil {
helpers.Error(nil, err)
RenderError(rw, err)
return
}
env[strings.ToUpper(name)] = value
err = models.PutEnvironment(app, env)
if err != nil {
helpers.Error(nil, err)
RenderError(rw, err)
return
}
RenderText(rw, "ok")
}
开发者ID:nguyendangminh,项目名称:kernel,代码行数:27,代码来源:environment.go
示例10: AppDelete
func AppDelete(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("delete").Start()
vars := mux.Vars(r)
name := vars["app"]
app, err := models.GetApp(name)
if awsError(err) == "ValidationError" {
RenderNotFound(rw, fmt.Sprintf("no such app: %s", name))
return
}
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=app.get app=%q", app.Name)
err = app.Delete()
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=app.delete app=%q", app.Name)
RenderText(rw, "ok")
}
开发者ID:oren,项目名称:kernel,代码行数:33,代码来源:apps.go
示例11: AppNameAvailable
func AppNameAvailable(rw http.ResponseWriter, r *http.Request) {
app, _ := models.GetApp(mux.Vars(r)["app"])
if app != nil {
RenderText(rw, "false")
} else {
RenderText(rw, "true")
}
}
开发者ID:oren,项目名称:kernel,代码行数:9,代码来源:apps.go
示例12: AppUpdate
func AppUpdate(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("update").Start()
vars := mux.Vars(r)
name := vars["app"]
app, err := models.GetApp(name)
if err != nil {
log.Error(err)
RenderError(rw, err)
return
}
params := map[string]string{}
if process := GetForm(r, "process"); process != "" {
process = models.UpperName(process)
if count := GetForm(r, "count"); count != "" {
params[process+"DesiredCount"] = count
}
if cpu := GetForm(r, "cpu"); cpu != "" {
params[process+"Cpu"] = cpu
}
if mem := GetForm(r, "mem"); mem != "" {
params[process+"Memory"] = mem
}
}
if len(params) > 0 {
err := app.UpdateParams(params)
if ae, ok := err.(awserr.Error); ok {
if ae.Code() == "ValidationError" {
switch {
case strings.Index(ae.Error(), "No updates are to be performed") > -1:
RenderNotFound(rw, fmt.Sprintf("no updates are to be performed: %s", name))
return
case strings.Index(ae.Error(), "can not be updated") > -1:
RenderNotFound(rw, fmt.Sprintf("app is already updating: %s", name))
return
}
}
}
if err != nil {
log.Error(err)
RenderError(rw, err)
return
}
}
Redirect(rw, r, fmt.Sprintf("/apps/%s", name))
}
开发者ID:2opremio,项目名称:kernel,代码行数:57,代码来源:apps.go
示例13: AppStream
func AppStream(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("stream").Start()
app := mux.Vars(r)["app"]
ws, err := upgrader.Upgrade(rw, r, nil)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
log.Success("step=upgrade app=%q", app)
defer ws.Close()
a, err := models.GetApp(mux.Vars(r)["app"])
if awsError(err) == "ValidationError" {
ws.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("ERROR: no such app: %s\n", app)))
return
}
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
logs := make(chan []byte)
done := make(chan bool)
a.SubscribeLogs(logs, done)
for data := range logs {
ws.WriteMessage(websocket.TextMessage, data)
}
log.Success("step=ended app=%q", app)
}
开发者ID:oren,项目名称:kernel,代码行数:41,代码来源:apps.go
示例14: ServiceLogs
func ServiceLogs(rw http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["service"]
service, err := models.GetServiceFromName(name)
if err != nil {
RenderError(rw, err)
return
}
RenderPartial(rw, "service", "logs", service)
}
开发者ID:nguyendangminh,项目名称:kernel,代码行数:12,代码来源:services.go
示例15: ClusterTop
func ClusterTop(rw http.ResponseWriter, r *http.Request) {
name := aws.String(os.Getenv("RACK"))
res, err := models.CloudFormation().DescribeStacks(&cloudformation.DescribeStacksInput{StackName: name})
if err != nil {
RenderError(rw, err)
return
}
if len(res.Stacks) == 0 {
RenderError(rw, fmt.Errorf("Stack %s does not exist", os.Getenv("RACK")))
return
}
stack := res.Stacks[0]
outputs := make(map[string]string)
for _, output := range stack.Outputs {
outputs[*output.OutputKey] = *output.OutputValue
}
cluster := outputs["Cluster"]
params := &cloudwatch.GetMetricStatisticsInput{
MetricName: aws.String(mux.Vars(r)["metric"]),
StartTime: aws.Time(time.Now().Add(-2 * time.Minute)),
EndTime: aws.Time(time.Now()),
Period: aws.Long(60),
Namespace: aws.String("AWS/ECS"),
Statistics: []*string{ // Required
aws.String("Maximum"),
aws.String("Average"),
aws.String("Minimum"),
},
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("ClusterName"),
Value: aws.String(cluster),
},
},
}
resp, err := models.CloudWatch().GetMetricStatistics(params)
if err != nil {
RenderError(rw, err)
return
}
RenderJson(rw, resp)
}
开发者ID:csquared,项目名称:kernel,代码行数:53,代码来源:top.go
示例16: AppStatus
func AppStatus(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("status").Start()
app, err := models.GetApp(mux.Vars(r)["app"])
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
RenderText(rw, app.Status)
}
开发者ID:oren,项目名称:kernel,代码行数:13,代码来源:apps.go
示例17: ProcessLogs
func ProcessLogs(rw http.ResponseWriter, r *http.Request) {
// log := processesLogger("logs").Start()
vars := mux.Vars(r)
app := vars["app"]
process := vars["process"]
params := map[string]string{
"App": app,
"Process": process,
}
RenderPartial(rw, "process", "logs", params)
}
开发者ID:2opremio,项目名称:kernel,代码行数:14,代码来源:processes.go
示例18: ServiceStatus
func ServiceStatus(rw http.ResponseWriter, r *http.Request) {
log := servicesLogger("show").Start()
name := mux.Vars(r)["service"]
service, err := models.GetServiceFromName(name)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
RenderText(rw, service.Status)
}
开发者ID:2opremio,项目名称:kernel,代码行数:14,代码来源:services.go
示例19: AppDebug
func AppDebug(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("environment").Start()
app := mux.Vars(r)["app"]
a, err := models.GetApp(app)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
RenderPartial(rw, "app", "debug", a)
}
开发者ID:oren,项目名称:kernel,代码行数:15,代码来源:apps.go
示例20: AppResources
func AppResources(rw http.ResponseWriter, r *http.Request) {
log := appsLogger("resources").Start()
app := mux.Vars(r)["app"]
resources, err := models.ListResources(app)
if err != nil {
helpers.Error(log, err)
RenderError(rw, err)
return
}
RenderPartial(rw, "app", "resources", resources)
}
开发者ID:oren,项目名称:kernel,代码行数:15,代码来源:apps.go
注:本文中的github.com/convox/kernel/Godeps/_workspace/src/github.com/gorilla/mux.Vars函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论