Small fixes to getting character images
All checks were successful
Build / build (push) Successful in 44s
Publish / publish (push) Successful in 51s

This commit is contained in:
2025-11-07 20:24:46 +01:00
parent 61cab73ffc
commit cff777f278
3 changed files with 9 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ import (
"strings"
)
func GetCharacters() []string {
func GetCharacterList() []string {
charactersPath := os.Getenv("CHARACTERS_PATH")
files, err := os.ReadDir(charactersPath)
if err != nil {
@@ -23,11 +23,11 @@ func GetCharacters() []string {
}
func GetCharacter(character string) string {
musicPath := os.Getenv("MUSIC_PATH")
charactersPath := musicPath + "characters/"
return charactersPath + character
charactersPath := os.Getenv("CHARACTERS_PATH")
return charactersPath + "/" + character
}
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"))
}

View File

@@ -42,12 +42,12 @@ func (i *IndexHandler) HealthCheck(ctx echo.Context) error {
return ctx.JSON(http.StatusOK, db.Health())
}
func (i *IndexHandler) GetCharacters(ctx echo.Context) error {
characters := backend.GetCharacters()
func (i *IndexHandler) GetCharacterList(ctx echo.Context) error {
characters := backend.GetCharacterList()
return ctx.JSON(http.StatusOK, characters)
}
func (i *IndexHandler) GetCharacter(ctx echo.Context) error {
character := ctx.QueryParam("character")
character := ctx.QueryParam("name")
return ctx.File(backend.GetCharacter(character))
}

View File

@@ -64,7 +64,7 @@ func (s *Server) RegisterRoutes() http.Handler {
e.GET("/dbtest", index.GetDBTest)
e.GET("/health", index.HealthCheck)
e.GET("/character", index.GetCharacter)
e.GET("/characters", index.GetCharacters)
e.GET("/characters", index.GetCharacterList)
download := NewDownloadHandler()
e.GET("/download", download.checkLatest)