Small fixes to getting character images
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetCharacters() []string {
|
func GetCharacterList() []string {
|
||||||
charactersPath := os.Getenv("CHARACTERS_PATH")
|
charactersPath := os.Getenv("CHARACTERS_PATH")
|
||||||
files, err := os.ReadDir(charactersPath)
|
files, err := os.ReadDir(charactersPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -23,11 +23,11 @@ func GetCharacters() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetCharacter(character string) string {
|
func GetCharacter(character string) string {
|
||||||
musicPath := os.Getenv("MUSIC_PATH")
|
charactersPath := os.Getenv("CHARACTERS_PATH")
|
||||||
charactersPath := musicPath + "characters/"
|
return charactersPath + "/" + character
|
||||||
return charactersPath + character
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isImage(entry os.DirEntry) bool {
|
func isImage(entry os.DirEntry) bool {
|
||||||
return !entry.IsDir() && (strings.HasSuffix(entry.Name(), ".jpg") || strings.HasSuffix(entry.Name(), ".png"))
|
return !entry.IsDir() && (strings.HasSuffix(entry.Name(), ".jpg") || strings.HasSuffix(entry.Name(), ".jpeg") ||
|
||||||
|
strings.HasSuffix(entry.Name(), ".png"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ func (i *IndexHandler) HealthCheck(ctx echo.Context) error {
|
|||||||
return ctx.JSON(http.StatusOK, db.Health())
|
return ctx.JSON(http.StatusOK, db.Health())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexHandler) GetCharacters(ctx echo.Context) error {
|
func (i *IndexHandler) GetCharacterList(ctx echo.Context) error {
|
||||||
characters := backend.GetCharacters()
|
characters := backend.GetCharacterList()
|
||||||
return ctx.JSON(http.StatusOK, characters)
|
return ctx.JSON(http.StatusOK, characters)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexHandler) GetCharacter(ctx echo.Context) error {
|
func (i *IndexHandler) GetCharacter(ctx echo.Context) error {
|
||||||
character := ctx.QueryParam("character")
|
character := ctx.QueryParam("name")
|
||||||
return ctx.File(backend.GetCharacter(character))
|
return ctx.File(backend.GetCharacter(character))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (s *Server) RegisterRoutes() http.Handler {
|
|||||||
e.GET("/dbtest", index.GetDBTest)
|
e.GET("/dbtest", index.GetDBTest)
|
||||||
e.GET("/health", index.HealthCheck)
|
e.GET("/health", index.HealthCheck)
|
||||||
e.GET("/character", index.GetCharacter)
|
e.GET("/character", index.GetCharacter)
|
||||||
e.GET("/characters", index.GetCharacters)
|
e.GET("/characters", index.GetCharacterList)
|
||||||
|
|
||||||
download := NewDownloadHandler()
|
download := NewDownloadHandler()
|
||||||
e.GET("/download", download.checkLatest)
|
e.GET("/download", download.checkLatest)
|
||||||
|
|||||||
Reference in New Issue
Block a user