8f8b555ea5
Build / build (push) Successful in 48s
- Split IndexHandler into HealthHandler, VersionHandler, and CharacterHandler - Rename index.go to version.go in backend - Change VersionData.Changelog from string to []string - Add changelog entries for issues #16-#23 - Remove TestDB function and related code - Fix import ordering in several files Closes #21, #22 References #16, #17, #18, #19, #20, #23 Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v5"
|
|
"music-server/internal/backend"
|
|
)
|
|
|
|
type CharacterHandler struct {
|
|
}
|
|
|
|
func NewCharacterHandler() *CharacterHandler {
|
|
return &CharacterHandler{}
|
|
}
|
|
|
|
// GetCharacterList godoc
|
|
// @Summary Get list of characters
|
|
// @Description Returns a list of all available characters
|
|
// @Tags characters
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {array} string
|
|
// @Router /characters [get]
|
|
func (c *CharacterHandler) GetCharacterList(ctx *echo.Context) error {
|
|
characters := backend.GetCharacterList()
|
|
return ctx.JSON(http.StatusOK, characters)
|
|
}
|
|
|
|
// GetCharacter godoc
|
|
// @Summary Get character image
|
|
// @Description Returns the image for a specific character
|
|
// @Tags characters
|
|
// @Accept json
|
|
// @Produce image/png
|
|
// @Param name query string true "Character name"
|
|
// @Success 200 {file} file
|
|
// @Router /character [get]
|
|
func (c *CharacterHandler) GetCharacter(ctx *echo.Context) error {
|
|
character := ctx.QueryParam("name")
|
|
return ctx.File(backend.GetCharacter(character))
|
|
}
|