Use wildcard in asset path
This commit is contained in:
13
api.go
13
api.go
@@ -45,7 +45,7 @@ func assetContentType(name string) string {
|
|||||||
|
|
||||||
func setupRoutes(router *gin.Engine) {
|
func setupRoutes(router *gin.Engine) {
|
||||||
router.GET("/", API_Home)
|
router.GET("/", API_Home)
|
||||||
router.GET("/static/:type/:name", API_ServeAsset)
|
router.GET("/static/*path", API_ServeAsset)
|
||||||
|
|
||||||
api := router.Group("/api")
|
api := router.Group("/api")
|
||||||
{
|
{
|
||||||
@@ -315,13 +315,8 @@ func API_Bookmarks(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func API_ServeAsset(c *gin.Context) {
|
func API_ServeAsset(c *gin.Context) {
|
||||||
file := fmt.Sprintf(
|
path := "static" + c.Params.ByName("path")
|
||||||
"static/%s/%s",
|
data, err := Asset(path)
|
||||||
c.Params.ByName("type"),
|
|
||||||
c.Params.ByName("name"),
|
|
||||||
)
|
|
||||||
|
|
||||||
data, err := Asset(file)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(400, err.Error())
|
c.String(400, err.Error())
|
||||||
@@ -333,5 +328,5 @@ func API_ServeAsset(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Data(200, assetContentType(file), data)
|
c.Data(200, assetContentType(path), data)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user