mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 09:18:31 +02:00
fix(api): correct error formatting
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
|||||||
routeApi "github.com/yusing/go-proxy/internal/api/v1/route"
|
routeApi "github.com/yusing/go-proxy/internal/api/v1/route"
|
||||||
"github.com/yusing/go-proxy/internal/auth"
|
"github.com/yusing/go-proxy/internal/auth"
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
"github.com/yusing/go-proxy/internal/common"
|
||||||
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @title GoDoxy API
|
// @title GoDoxy API
|
||||||
@@ -188,8 +189,9 @@ func ErrorHandler() gin.HandlerFunc {
|
|||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
c.Next()
|
c.Next()
|
||||||
if len(c.Errors) > 0 {
|
if len(c.Errors) > 0 {
|
||||||
|
logger := log.With().Str("uri", c.Request.RequestURI).Logger()
|
||||||
for _, err := range c.Errors {
|
for _, err := range c.Errors {
|
||||||
log.Err(err.Err).Str("uri", c.Request.RequestURI).Msg("Internal error")
|
gperr.LogError("Internal error", err.Err, &logger)
|
||||||
}
|
}
|
||||||
if !isWebSocketRequest(c) {
|
if !isWebSocketRequest(c) {
|
||||||
c.JSON(http.StatusInternalServerError, apitypes.Error("Internal server error"))
|
c.JSON(http.StatusInternalServerError, apitypes.Error("Internal server error"))
|
||||||
|
|||||||
Reference in New Issue
Block a user