本文整理匯總了Golang中github.com/outbrain/orchestrator/Godeps/_workspace/src/github.com/martini-contrib/render.Render.JSON方法的典型用法代碼示例。如果您正苦於以下問題:Golang Render.JSON方法的具體用法?Golang Render.JSON怎麽用?Golang Render.JSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/outbrain/orchestrator/Godeps/_workspace/src/github.com/martini-contrib/render.Render
的用法示例。
在下文中一共展示了Render.JSON方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetHostAttribute
// SetHostAttribute is a utility method that allows per-host key-value store.
func (this *HttpAgentsAPI) SetHostAttribute(params martini.Params, r render.Render, req *http.Request) {
err := attributes.SetHostAttributes(params["host"], params["attrVame"], params["attrValue"])
if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}
r.JSON(200, (err == nil))
}
示例2: GetHostAttributeByAttributeName
// GetHostAttributeByAttributeName returns a host attribute
func (this *HttpAgentsAPI) GetHostAttributeByAttributeName(params martini.Params, r render.Render, req *http.Request) {
output, err := attributes.GetHostAttributesByAttribute(params["attr"], req.URL.Query().Get("valueMatch"))
if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}
r.JSON(200, output)
}
示例3: ClusterByAlias
func (this *HttpWeb) ClusterByAlias(params martini.Params, r render.Render, req *http.Request, user auth.User) {
clusterName, err := inst.GetClusterByAlias(params["clusterAlias"])
// Willing to accept the case of multiple clusters; we just present one
if clusterName == "" && err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}
params["clusterName"] = clusterName
this.Cluster(params, r, req, user)
}
示例4: AgentsInstances
// AgentsInstances provides list of assumed MySQL instances (host:port)
func (this *HttpAgentsAPI) AgentsInstances(params martini.Params, r render.Render, req *http.Request) string {
agents, err := agent.ReadAgents()
hostnames := []string{}
for _, agent := range agents {
hostnames = append(hostnames, fmt.Sprintf("%s:%d", agent.Hostname, agent.MySQLPort))
}
if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return ""
}
if req.URL.Query().Get("format") == "txt" {
return strings.Join(hostnames, "\n")
} else {
r.JSON(200, hostnames)
}
return ""
}
示例5: SubmitAgent
// SubmitAgent registeres an agent. It is initiated by an agent to register itself.
func (this *HttpAgentsAPI) SubmitAgent(params martini.Params, r render.Render) {
port, err := strconv.Atoi(params["port"])
if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: err.Error()})
return
}
output, err := agent.SubmitAgent(params["host"], port, params["token"])
if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: err.Error()})
return
}
r.JSON(200, output)
}
示例6: ClusterByInstance
func (this *HttpWeb) ClusterByInstance(params martini.Params, r render.Render, req *http.Request, user auth.User) {
instanceKey, err := this.getInstanceKey(params["host"], params["port"])
if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: err.Error()})
return
}
instance, found, err := inst.ReadInstance(&instanceKey)
if (!found) || (err != nil) {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("Cannot read instance: %+v", instanceKey)})
return
}
// Willing to accept the case of multiple clusters; we just present one
if instance.ClusterName == "" && err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
return
}
params["clusterName"] = instance.ClusterName
this.Cluster(params, r, req, user)
}
示例7: AgentPing
func (this *HttpAgentsAPI) AgentPing(params martini.Params, r render.Render, req *http.Request) {
r.JSON(200, "OK")
}