add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
package exception
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"epic-ent/internal/domain/vo"
|
||||
)
|
||||
|
||||
func RegisterErrorHandler(e *echo.Echo) {
|
||||
func RegisterErrorHandler(e *echo.Echo, logger *zap.Logger) {
|
||||
e.HTTPErrorHandler = func(err error, c echo.Context) {
|
||||
code := http.StatusInternalServerError
|
||||
msg := err.Error()
|
||||
@@ -19,6 +21,14 @@ func RegisterErrorHandler(e *echo.Echo) {
|
||||
}
|
||||
}
|
||||
|
||||
verbose := fmt.Sprintf("%+v", err)
|
||||
logger.With(
|
||||
zap.Int("status", code),
|
||||
zap.String("path", c.Path()),
|
||||
zap.String("method", c.Request().Method),
|
||||
zap.Error(err),
|
||||
).Error(verbose)
|
||||
|
||||
_ = c.JSON(code, vo.Error(msg))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user