add initial application structure with configuration, logging, and health check endpoints

This commit is contained in:
kever
2026-01-15 21:39:15 +08:00
parent fed727e593
commit ed8c3d55b8
103 changed files with 39974 additions and 80 deletions

View File

@@ -1,14 +1,24 @@
package exception
import (
"net/http"
"github.com/labstack/echo/v4"
"epic-ent/internal/domain/vo"
)
func RegisterErrorHandler(e *echo.Echo) {
e.HTTPErrorHandler = func(err error, c echo.Context) {
_ = c.JSON(500, map[string]any{
"code": "INTERNAL_ERROR",
"message": err.Error(),
})
code := http.StatusInternalServerError
msg := err.Error()
if he, ok := err.(*echo.HTTPError); ok {
code = he.Code
if he.Message != nil {
msg = he.Message.(string)
}
}
_ = c.JSON(code, vo.Error(msg))
}
}