本文整理匯總了Golang中net/http.Request.Recstr方法的典型用法代碼示例。如果您正苦於以下問題:Golang Request.Recstr方法的具體用法?Golang Request.Recstr怎麽用?Golang Request.Recstr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/http.Request
的用法示例。
在下文中一共展示了Request.Recstr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doGetHead
//doGetHead renders records contents(get) or id+timestamp(head) who has id and
// whose stamp is in range of one specified by url.
func doGetHead(w http.ResponseWriter, r *http.Request) {
s, err := new(w, r)
if err != nil {
log.Println(err)
return
}
reg := regexp.MustCompile("^(get|head|removed)/([0-9A-Za-z_]+)/?([-0-9A-Za-z/]*)$")
m := reg.FindStringSubmatch(s.Path())
if m == nil {
log.Println("illegal url", s.Path())
return
}
method, datfile, stamp := m[1], m[2], m[3]
ca := thread.NewCache(datfile)
begin, end, id := s.parseStamp(stamp, math.MaxInt32)
var recs record.Map
if method == "removed" {
recs = ca.LoadRecords(record.Removed)
} else {
recs = ca.LoadRecords(record.Alive)
}
for _, r := range recs {
if r.InRange(begin, end, id) {
if method == "get" {
if err := r.Load(); err != nil {
log.Println(err)
continue
}
fmt.Fprintln(s.WR, r.Recstr())
continue
}
fmt.Fprintln(s.WR, strings.Replace(r.Idstr(), "_", "<>", -1))
}
}
if method == "get" {
updateque.UpdatedRecord.Inform(datfile, id, begin, end)
}
}