Files
honoka-chan/internal/handler/api/unit/unit.go
T
YumeMichi 0dd5df0302 Unify fallback and unimplemented API error handling
- Add a shared common error response schema and unknown error code for business-level fallbacks
- Return business error payloads for router NoRoute and NoMethod fallbacks
- Align the existing event list fallback response with the shared error structure
- Introduce an explicit unimplemented API error type instead of relying on formatted strings
- Make /api batch dispatch return per-item status 600 error entries for unimplemented modules and actions without failing the whole batch

Signed-off-by: Sean Du <do4suki@gmail.com>
2026-06-06 17:13:27 +08:00

30 lines
675 B
Go

package unit
import (
honokautils "honoka-chan/internal/utils"
"github.com/gin-gonic/gin"
)
func UnitApi(ctx *gin.Context, action string) (res any, err error) {
switch action {
case "accessoryAll":
res, err = unitAccessoryAll(ctx)
case "accessoryMaterialAll":
res, err = unitAccessoryMaterialAll()
case "accessoryTab":
res, err = unitAccessoryTab()
case "deckInfo":
res, err = unitDeckInfo(ctx)
case "removableSkillInfo":
res, err = unitRemovableSkillInfo(ctx)
case "supporterAll":
res, err = unitSupporterAll()
case "unitAll":
res, err = unitAll(ctx)
default:
err = honokautils.NewUnimplementedActionError("unit", action)
}
return res, err
}