本文整理汇总了Golang中github.com/urandom/webfw/context.Context.Param方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Param方法的具体用法?Golang Context.Param怎么用?Golang Context.Param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/urandom/webfw/context.Context
的用法示例。
在下文中一共展示了Context.Param方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Handler
//.........这里部分代码省略.........
special.Items = append(special.Items, ttRssFeedListCategoryFeed(user, nil, TTRSS_ALL_ID, false))
special.Items = append(special.Items, ttRssFeedListCategoryFeed(user, nil, TTRSS_FRESH_ID, false))
special.Items = append(special.Items, ttRssFeedListCategoryFeed(user, nil, TTRSS_FAVORITE_ID, false))
special.Items = append(special.Items, ttRssFeedListCategoryFeed(user, nil, TTRSS_PUBLISHED_ID, false))
special.Items = append(special.Items, ttRssFeedListCategoryFeed(user, nil, TTRSS_ARCHIVED_ID, false))
special.Items = append(special.Items, ttRssFeedListCategoryFeed(user, nil, TTRSS_RECENTLY_READ_ID, false))
items = append(items, special)
tf := user.AllTaggedFeeds()
uncat := ttRssCategory{Id: "CAT:0", Items: []ttRssCategory{}, BareId: 0, Name: "Uncategorized", Type: "category"}
tagCategories := map[content.Tag]ttRssCategory{}
for _, f := range tf {
tags := f.Tags()
item := ttRssFeedListCategoryFeed(user, f, f.Data().Id, true)
if len(tags) > 0 {
for _, t := range tags {
var c ttRssCategory
if cached, ok := tagCategories[t]; ok {
c = cached
} else {
c = ttRssCategory{
Id: "CAT:" + strconv.FormatInt(int64(t.Data().Id), 10),
BareId: data.FeedId(t.Data().Id),
Name: string(t.Data().Value),
Type: "category",
Items: []ttRssCategory{},
}
}
c.Items = append(c.Items, item)
tagCategories[t] = c
}
} else {
uncat.Items = append(uncat.Items, item)
}
}
categories := []ttRssCategory{uncat}
for _, c := range tagCategories {
categories = append(categories, c)
}
for _, c := range categories {
if len(c.Items) == 1 {
c.Param = "(1 feed)"
} else {
c.Param = fmt.Sprintf("(%d feed)", len(c.Items))
}
items = append(items, c)
}
fl := ttRssCategory{Identifier: "id", Label: "name"}
fl.Items = items
if user.HasErr() {
err = user.Err()
} else {
con = ttRssFeedTreeContent{Categories: fl}
}
default:
errType = "UNKNOWN_METHOD"
con = ttRssGenericContent{Method: req.Op}
}
}
if err == nil && errType == "" {
resp.Status = TTRSS_API_STATUS_OK
} else {
logger.Infof("Error processing TT-RSS API request: %s %v\n", errType, err)
resp.Status = TTRSS_API_STATUS_ERR
con = ttRssErrorContent{Error: errType}
}
var b []byte
b, err = json.Marshal(con)
if err == nil {
resp.Content = json.RawMessage(b)
}
b, err = json.Marshal(&resp)
if err == nil {
w.Header().Set("Content-Type", "text/json")
w.Header().Set("Api-Content-Length", strconv.Itoa(len(b)))
w.Write(b)
logger.Debugf("Output for %s: %s\n", req.Op, string(b))
} else {
logger.Print(fmt.Errorf("TT-RSS error %s: %v", req.Op, err))
w.WriteHeader(http.StatusInternalServerError)
}
})
}