fix(all) Добавил раздачу картинок через бекенд
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -19,6 +20,12 @@ func GetItem(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if item.AvatarURL != "" {
|
||||
item.AvatarURL = fmt.Sprintf("/static/items/%s", item.AvatarURL)
|
||||
} else {
|
||||
item.AvatarURL = fmt.Sprintf("/static/items/background.png")
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, item)
|
||||
}
|
||||
|
||||
@@ -30,6 +37,14 @@ func GetAllItems(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items {
|
||||
if items[i].AvatarURL != "" {
|
||||
items[i].AvatarURL = fmt.Sprintf("/static/items/%s", items[i].AvatarURL)
|
||||
} else {
|
||||
items[i].AvatarURL = fmt.Sprintf("/static/items/background.png")
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, items)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user