Skip to content
Snippets Groups Projects
Commit 85879c94 authored by Ophestra's avatar Ophestra
Browse files

move image pages under /image

parent 8142d554
No related branches found
No related tags found
No related merge requests found
......@@ -286,6 +286,30 @@ func registerAPI() {
context.JSON(http.StatusOK, image)
})
router.GET(api.ImagePage, func(context *gin.Context) {
context.String(http.StatusOK, strconv.Itoa(instance.PageTotal(store.ImageRootPageVariant)))
})
router.GET(api.ImagePageField, func(context *gin.Context) {
param := context.Param("entry")
entry, err := strconv.Atoi(param)
if err != nil {
context.JSON(http.StatusBadRequest, api.Error{Error: err.Error()})
return
}
context.JSON(http.StatusOK, instance.Page(store.ImageRootPageVariant, entry))
})
router.GET(api.ImagePageImage, func(context *gin.Context) {
param := context.Param("entry")
entry, err := strconv.Atoi(param)
if err != nil {
context.JSON(http.StatusBadRequest, api.Error{Error: err.Error()})
return
}
context.JSON(http.StatusOK, instance.PageImages(store.ImageRootPageVariant, entry))
})
router.GET(api.ImageField, func(context *gin.Context) {
context.JSON(http.StatusOK, instance.ImageSnowflake(context.Param("flake")))
})
......@@ -508,30 +532,6 @@ func registerAPI() {
}
instance.TagType(context.Param("tag"), payload.Type)
})
router.GET(api.Page, func(context *gin.Context) {
context.String(http.StatusOK, strconv.Itoa(instance.PageTotal(store.ImageRootPageVariant)))
})
router.GET(api.PageField, func(context *gin.Context) {
param := context.Param("entry")
entry, err := strconv.Atoi(param)
if err != nil {
context.JSON(http.StatusBadRequest, api.Error{Error: err.Error()})
return
}
context.JSON(http.StatusOK, instance.Page(store.ImageRootPageVariant, entry))
})
router.GET(api.PageImage, func(context *gin.Context) {
param := context.Param("entry")
entry, err := strconv.Atoi(param)
if err != nil {
context.JSON(http.StatusBadRequest, api.Error{Error: err.Error()})
return
}
context.JSON(http.StatusOK, instance.PageImages(store.ImageRootPageVariant, entry))
})
}
func getUser(context *gin.Context) (store.User, bool) {
......
......@@ -4,6 +4,9 @@ const (
Base = "/api"
SingleUser = Base + "/single_user"
Image = Base + "/image"
ImagePage = Image + "/page"
ImagePageField = ImagePage + "/:entry"
ImagePageImage = ImagePageField + "/image"
ImageField = Image + "/:flake"
ImageFile = ImageField + "/file"
ImagePreview = ImageField + "/preview"
......@@ -15,9 +18,6 @@ const (
TagPage = TagField + "/page"
TagPageField = TagPage + "/:entry"
TagPageImage = TagPageField + "/image"
Page = Base + "/page"
PageField = Page + "/:entry"
PageImage = PageField + "/image"
Search = Base + "/search"
SearchField = Search + "/:tags"
User = Base + "/user"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment