本文整理匯總了Golang中camlistore/org/pkg/search.Handler.Describe方法的典型用法代碼示例。如果您正苦於以下問題:Golang Handler.Describe方法的具體用法?Golang Handler.Describe怎麽用?Golang Handler.Describe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類camlistore/org/pkg/search.Handler
的用法示例。
在下文中一共展示了Handler.Describe方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: fileInfoPacked
// Fast path for blobpacked.
func fileInfoPacked(sh *search.Handler, src blob.Fetcher, req *http.Request, file blob.Ref) (packFileInfo fileInfo, ok bool) {
if sh == nil {
return fileInfo{whyNot: "no search"}, false
}
wf, ok := src.(blobserver.WholeRefFetcher)
if !ok {
return fileInfo{whyNot: "fetcher type"}, false
}
if req != nil && req.Header.Get("Range") != "" {
// TODO: not handled yet. Maybe not even important,
// considering rarity.
return fileInfo{whyNot: "range header"}, false
}
des, err := sh.Describe(&search.DescribeRequest{BlobRef: file})
if err != nil {
log.Printf("ui: fileInfoPacked: skipping fast path due to error from search: %v", err)
return fileInfo{whyNot: "search error"}, false
}
db, ok := des.Meta[file.String()]
if !ok || db.File == nil {
return fileInfo{whyNot: "search index doesn't know file"}, false
}
fi := db.File
if !fi.WholeRef.Valid() {
return fileInfo{whyNot: "no wholeref from search index"}, false
}
offset := int64(0)
rc, wholeSize, err := wf.OpenWholeRef(fi.WholeRef, offset)
if err == os.ErrNotExist {
return fileInfo{whyNot: "WholeRefFetcher returned ErrNotexist"}, false
}
if wholeSize != fi.Size {
log.Printf("ui: fileInfoPacked: OpenWholeRef size %d != index size %d; ignoring fast path", wholeSize, fi.Size)
return fileInfo{whyNot: "WholeRefFetcher and index don't agree"}, false
}
if err != nil {
log.Printf("ui: fileInfoPacked: skipping fast path due to error from WholeRefFetcher (%T): %v", src, err)
return fileInfo{whyNot: "WholeRefFetcher error"}, false
}
return fileInfo{
mime: fi.MIMEType,
name: fi.FileName,
size: fi.Size,
rs: readerutil.NewFakeSeeker(rc, fi.Size-offset),
close: rc.Close,
}, true
}