本文整理汇总了Golang中github.com/JasonSoft/render.Render类的典型用法代码示例。如果您正苦于以下问题:Golang Render类的具体用法?Golang Render怎么用?Golang Render使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Render类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: deleteCollectionHandler
func deleteCollectionHandler(r render.Render, params martini.Params) {
collectionId, _ := strconv.Atoi(params["collectionId"])
collection := Collection{Id: collectionId, StoreId: aipOption.Store.Id}
err := collection.delete()
if err != nil {
logError(err.Error())
r.JSON(500, "error")
return
}
r.Status(200)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:11,代码来源:api.go
示例2: getProductHandler
func getProductHandler(req *http.Request, r render.Render, params martini.Params) {
var productId string = params["productId"]
link := LinkModel{Url: "http://abc"}
var product = Product{}
product.All = link
if productId == "1" {
links := [2]LinkModel{{Url: "Jaosn"}, {Url: "Hello"}}
product.All = links
}
r.JSON(200, product)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:14,代码来源:api.go
示例3: displayPage
func displayPage(r render.Render, myStore *Store, pageName string) {
var page *Page
for _, value := range *myStore.pages {
if value.Name == pageName {
page = &value
break
}
}
if page != nil {
context := TemplateContext{Page: page, Store: myStore}
r.HTML(200, page.TemplateName, context)
}
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:16,代码来源:page.go
示例4: getTemplatesHandler
func getTemplatesHandler(req *http.Request, r render.Render, params martini.Params) {
themeName := req.URL.Query().Get("theme")
if len(themeName) <= 0 {
r.JSON(404, "theme parameter was missing")
return
}
//ensure theme is valid
targetTheme := aipOption.Store.getTheme(themeName)
if targetTheme == nil {
r.JSON(404, "theme was not found")
return
}
templates := []Template{}
for _, template := range *aipOption.Store.templates {
if targetTheme.Id == template.ThemeId {
templates = append(templates, template)
}
}
r.JSON(200, templates)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:26,代码来源:api.go
示例5: createCollectionHandler
func createCollectionHandler(r render.Render, collection Collection) {
collection.StoreId = aipOption.Store.Id
err := collection.create()
if err != nil {
if appErr, ok := err.(*appError); ok {
r.JSON(500, appErr.Error())
return
} else {
logError(err.Error())
r.JSON(500, "error")
return
}
}
location := fmt.Sprintf("/api/v1/collections/%d", collection.Id)
r.Header().Add("location", location)
r.Status(201)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:19,代码来源:api.go
示例6: getCollectionsHandler
func getCollectionsHandler(r render.Render) {
collections, err := GetCollections(aipOption.Store.Id)
if err != nil {
if appErr, ok := err.(*appError); ok {
r.JSON(500, appErr.Error())
return
} else {
r.JSON(500, "error")
return
}
}
if collections == nil {
r.Status(200)
return
}
for i := range collections {
collection := &collections[i]
collection.toJsonForm()
}
r.JSON(200, collections)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:21,代码来源:api.go
示例7: getCollectionHandler
func getCollectionHandler(r render.Render, params martini.Params) {
collectionId, err := strconv.Atoi(params["collectionId"])
if err != nil {
r.JSON(500, "bad request")
return
}
collection, err := GetCollection(aipOption.Store.Id, collectionId)
if err != nil {
r.JSON(500, "error")
return
}
if collection == nil {
r.JSON(404, "collection is not found")
return
}
collection.toJsonForm()
r.JSON(200, collection)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:23,代码来源:api.go
示例8: updateCollectionHandler
func updateCollectionHandler(r render.Render, collection Collection, params martini.Params) {
collection.StoreId = aipOption.Store.Id
err := collection.update()
if err != nil {
if appErr, ok := err.(*appError); ok {
r.JSON(500, appErr.Error())
return
} else {
logError(err.Error())
r.JSON(500, "error")
return
}
}
r.Status(200)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:16,代码来源:api.go
示例9: getPageHandler
func getPageHandler(req *http.Request, r render.Render, params martini.Params) {
pages := getPages(aipOption.Store.Id)
r.JSON(200, pages)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:4,代码来源:api.go
示例10: getThemesHandler
func getThemesHandler(r render.Render) {
themes := getThemes(aipOption.Store.Id)
r.JSON(200, themes)
}
开发者ID:JasonSoft,项目名称:MyGo,代码行数:4,代码来源:api.go
注:本文中的github.com/JasonSoft/render.Render类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论