admin: Use gin-gonic as router
This commit is contained in:
parent
83468ad723
commit
8b3fbdb64a
32 changed files with 2748 additions and 1598 deletions
|
|
@ -5,13 +5,14 @@ import (
|
|||
"image"
|
||||
"image/jpeg"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
"golang.org/x/image/draw"
|
||||
|
||||
|
|
@ -235,16 +236,23 @@ func SyncThemes(i Importer) (errs []string) {
|
|||
}
|
||||
|
||||
// ApiListRemoteThemes is an accessor letting foreign packages to access remote themes list.
|
||||
func ApiListRemoteThemes(_ httprouter.Params, _ []byte) (interface{}, error) {
|
||||
return GetThemes(GlobalImporter)
|
||||
func ApiListRemoteThemes(c *gin.Context) {
|
||||
themes, err := GetThemes(GlobalImporter)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, themes)
|
||||
}
|
||||
|
||||
// ApiListRemoteTheme is an accessor letting foreign packages to access remote main theme attributes.
|
||||
func ApiGetRemoteTheme(ps httprouter.Params, _ []byte) (interface{}, error) {
|
||||
r, errs := BuildTheme(GlobalImporter, ps.ByName("thid"))
|
||||
func ApiGetRemoteTheme(c *gin.Context) {
|
||||
r, errs := BuildTheme(GlobalImporter, c.Params.ByName("thid"))
|
||||
if r == nil {
|
||||
return r, fmt.Errorf("%q", errs)
|
||||
} else {
|
||||
return r, nil
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Errorf("%q", errs)})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, r)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue