本文整理汇总了Golang中net/http.Request.Time方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Time方法的具体用法?Golang Request.Time怎么用?Golang Request.Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/http.Request
的用法示例。
在下文中一共展示了Request.Time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: quakeInVolcanoRegionStatsProto
func quakeInVolcanoRegionStatsProto(r *http.Request, h http.Header, b *bytes.Buffer) *weft.Result {
if res := weft.CheckQuery(r, []string{}, []string{}); !res.Ok {
return res
}
var q haz.QuakeStats
var rows *sql.Rows
var err error
var volcanoId string
if volcanoId, err = getVolcanoRegionStats(r); err != nil {
return weft.BadRequest(err.Error())
}
if rows, err = db.Query(fmt.Sprintf(quakesPerDayInVolcanoRegionSQL, 90), volcanoId); err != nil {
return weft.ServiceUnavailableError(err)
}
defer rows.Close()
for rows.Next() {
var t time.Time
var r haz.Rate
if err = rows.Scan(&t, &r.Count); err != nil {
return weft.ServiceUnavailableError(err)
}
r.Time = &haz.Timestamp{Sec: t.Unix(), Nsec: int64(t.Nanosecond())}
q.PerDay = append(q.PerDay, &r)
}
rows.Close()
q.Year = make(map[int32]int32)
if rows, err = db.Query(fmt.Sprintf(sumMagsInVolcanoRegionSQL, 365), volcanoId); err != nil {
return weft.ServiceUnavailableError(err)
}
defer rows.Close()
for rows.Next() {
var k, v int32
if err = rows.Scan(&k, &v); err != nil {
return weft.ServiceUnavailableError(err)
}
q.Year[k] = v
}
rows.Close()
q.Month = make(map[int32]int32)
if rows, err = db.Query(fmt.Sprintf(sumMagsInVolcanoRegionSQL, 28), volcanoId); err != nil {
return weft.ServiceUnavailableError(err)
}
defer rows.Close()
for rows.Next() {
var k, v int32
if err = rows.Scan(&k, &v); err != nil {
return weft.ServiceUnavailableError(err)
}
q.Month[k] = v
}
rows.Close()
q.Week = make(map[int32]int32)
if rows, err = db.Query(fmt.Sprintf(sumMagsInVolcanoRegionSQL, 7), volcanoId); err != nil {
return weft.ServiceUnavailableError(err)
}
defer rows.Close()
for rows.Next() {
var k, v int32
if err = rows.Scan(&k, &v); err != nil {
return weft.ServiceUnavailableError(err)
}
q.Week[k] = v
}
rows.Close()
var by []byte
if by, err = proto.Marshal(&q); err != nil {
return weft.ServiceUnavailableError(err)
}
b.Write(by)
h.Set("Content-Type", protobuf)
h.Set("Surrogate-Control", maxAge300)
return &weft.StatusOK
}