本文整理汇总了Golang中github.com/Unknwon/macaron.Render.JSON方法的典型用法代码示例。如果您正苦于以下问题:Golang Render.JSON方法的具体用法?Golang Render.JSON怎么用?Golang Render.JSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Unknwon/macaron.Render
的用法示例。
在下文中一共展示了Render.JSON方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: WI_JobQueueLen
//Monitor length of job queue stack
func WI_JobQueueLen(r macaron.Render, req *http.Request) {
req.ParseForm()
var success bool = false
var message interface{}
shpid := req.Form.Get("sheepid")
sheepobj, ok := sheep.SHEEPS[shpid]
if !ok {
message = "sheepid is unavaliable."
r.JSON(200, map[string]interface{}{"success": success, "message": message})
return
} else {
success = true
}
message = sheepobj.JobLen()
r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
示例2: WI_FailEscape
//Escape the last failed job
func WI_FailEscape(r macaron.Render, req *http.Request) {
req.ParseForm()
var success bool = false
var message string = ""
shpid := req.Form.Get("sheepid")
sheepobj, ok := sheep.SHEEPS[shpid]
if !ok {
message = "sheepid is unavaliable."
r.JSON(200, map[string]interface{}{"success": success, "message": message})
return
} else {
success = true
}
sheepobj.SetLastFail(nil)
r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
示例3: WI_SheepStatus
//sheeps` status
func WI_SheepStatus(r macaron.Render, req *http.Request) {
var success bool = true
var message interface{}
var data []SHEEPSTATUS
var tmp SHEEPSTATUS
for shpid, sheepobj := range sheep.SHEEPS {
rs := sheepobj.RuningStatus()
tmp.ID = shpid
tmp.ENABLE = rs["ENABLE"].(bool)
tmp.STATUS = rs["STATUS"].(int)
tmp.JOBQLEN = rs["JOBQLEN"].(int)
tmp.FOQLEN = rs["FOQLEN"].(int)
tmp.CAPACITY = rs["CAPACITY"].(int)
data = append(data, tmp)
}
r.JSON(200, map[string]interface{}{"success": success, "message": message, "data": data})
}
示例4: WI_JobAssign
//Assign jobs
func WI_JobAssign(r macaron.Render, req *http.Request) {
REQ += 1
req.ParseForm()
var success bool = false
var message interface{}
var isbypass bool = false
bypass := req.Form.Get("bypass")
key := req.Form.Get("key")
if bypass == "1" { // check if bypass mode is
isbypass = true
}
isOk, message := sheep.Assign(req.Form.Get("info"), key, isbypass)
success = isOk
message_e, isError := message.(error)
if isError {
message = message_e.Error()
}
r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
示例5: WI_HostEnable
func WI_HostEnable(r macaron.Render, req *http.Request) {
req.ParseForm()
var success bool = false
var message string = ""
shpid := req.Form.Get("sheepid")
sheepobj, ok := sheep.SHEEPS[shpid]
if !ok {
message = "sheepid is unavaliable."
r.JSON(200, map[string]interface{}{"success": success, "message": message})
return
}
enable := req.Form.Get("enable")
switch enable {
case "0":
sheepobj.Disable()
success = true
case "1":
sheepobj.Enable()
success = true
default:
message = fmt.Sprintf("enable type '%s'is undefined.", enable)
}
r.JSON(200, map[string]interface{}{"success": success, "message": message})
}