本文整理汇总了Golang中github.com/benbearchen/asuran/web/proxy/life.Life.LookHistoryByID方法的典型用法代码示例。如果您正苦于以下问题:Golang Life.LookHistoryByID方法的具体用法?Golang Life.LookHistoryByID怎么用?Golang Life.LookHistoryByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/benbearchen/asuran/web/proxy/life.Life
的用法示例。
在下文中一共展示了Life.LookHistoryByID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: formatHistoryEventDataList
func formatHistoryEventDataList(events []*life.HistoryEvent, client string, f *life.Life) []historyEventData {
list := make([]historyEventData, 0, len(events))
even := true
for _, e := range events {
d := historyEventData{}
d.OPs = make([]opData, 0)
d.Client = client
even = !even
d.Even = even
d.Time = e.Time.Format("2006-01-02 15:04:05")
s := strings.Split(e.String, " ")
if len(s) >= 3 && s[0] == "domain" {
domain := s[2]
d.Domain = "域名 " + s[1] + " " + domain
d.OPs = append(d.OPs, opData{"代理域名", "domain/redirect", domain, client})
if len(s) >= 4 {
d.DomainIP = s[3]
}
} else if len(s) >= 3 && s[0] == "proxy" {
url := s[1]
d.URL = url
if len(s) >= 4 {
d.URL += " " + s[3]
}
d.URLID = s[2]
if id, err := strconv.ParseInt(d.URLID, 10, 32); err == nil {
h := f.LookHistoryByID(uint32(id))
if h != nil {
status := h.Method
if h.ResponseCode >= 0 {
status += " " + strconv.Itoa(h.ResponseCode)
} else {
status += " 出错"
}
d.HttpStatus = status
}
}
if strings.HasPrefix(url, "http://") {
d.URLBody = url[7:]
} else {
d.URLBody = url
}
d.OPs = append(d.OPs, opData{"缓存", "url/store", d.URLID, client})
} else {
d.EventString = e.String
}
list = append(list, d)
}
return list
}