本文整理汇总了Golang中net/http.Request.Stages方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Stages方法的具体用法?Golang Request.Stages怎么用?Golang Request.Stages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/http.Request
的用法示例。
在下文中一共展示了Request.Stages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getReport
//.........这里部分代码省略.........
where := &genmai.Condition{}
for i, c := range cond {
if i < 1 {
where = dh.Where(c[0], c[1], c[2])
} else {
where = where.And(dh.Where(c[0], c[1], c[2]))
}
}
var reports []db.Report
dh.Select(&reports, where, order)
if len(reports) > limit {
res.NextStart = reports[limit].Start.Unix()
reports = reports[:len(reports)-1]
}
for _, report := range reports {
r := &Report{
Id: report.Id,
Status: report.Status,
Branch: report.Branch,
CompareUrl: report.CompareUrl,
Start: report.Start.Unix(),
End: report.End.Unix(),
}
var projects []db.Project
dh.Select(&projects, dh.Where("id", "=", report.ProjectId))
project := projects[0]
r.Project = &Project{
Id: project.Id,
Name: project.Name,
Repo: project.Repo,
}
var commits []db.Commit
dh.Select(&commits, dh.Where("report_id", "=", report.Id))
for _, commit := range commits {
r.Commits = append(r.Commits, &Commit{
Revision: commit.Revision,
Author: commit.Author,
Message: commit.Message,
Url: commit.Url,
})
}
var users []db.User
dh.Select(&users, dh.Where("id", "=", report.TriggeredBy))
user := users[0]
r.TriggeredBy.Name = user.Name
r.TriggeredBy.Url = user.Url
r.TriggeredBy.AvatarUrl = user.AvatarUrl
var stages []db.Stage
dh.Select(&stages, dh.Where("report_id", "=", report.Id).And(dh.Where("parent_stage_id", "=", 0)))
for _, stage := range stages {
s := &Stage{
Id: stage.Id,
Name: stage.Name,
Status: stage.Status,
Log: stage.Log,
Start: stage.Start.Unix(),
End: stage.End.Unix(),
}
var childStages []db.Stage
dh.Select(&childStages, dh.Where("report_id", "=", report.Id).And(dh.Where("parent_stage_id", "=", stage.Id)))
for _, childStage := range childStages {
s.Stages = append(s.Stages, &Stage{
Id: childStage.Id,
Name: childStage.Name,
Status: childStage.Status,
Log: childStage.Log,
Start: childStage.Start.Unix(),
End: childStage.End.Unix(),
})
}
r.Stages = append(r.Stages, s)
}
res.Reports = append(res.Reports, r)
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
var b []byte
if reportId != "" {
b, _ = json.Marshal(&struct{ Report *Report }{Report: res.Reports[0]})
} else {
b, _ = json.Marshal(res)
}
fmt.Fprint(w, string(b))
}