Use sockets for server creation progress

This commit is contained in:
Fran Jurmanović
2025-09-18 01:06:58 +02:00
parent 760412d7db
commit 901dbe697e
17 changed files with 1314 additions and 188 deletions

View File

@@ -66,12 +66,34 @@ func (ceh *ControllerErrorHandler) HandleError(c *fiber.Ctx, err error, statusCo
if errorResponse.Details == nil {
errorResponse.Details = make(map[string]string)
}
errorResponse.Details["method"] = c.Method()
errorResponse.Details["path"] = c.Path()
errorResponse.Details["ip"] = c.IP()
// Safely extract request details
func() {
defer func() {
if r := recover(); r != nil {
// If any of these panic, just skip adding the details
return
}
}()
errorResponse.Details["method"] = c.Method()
errorResponse.Details["path"] = c.Path()
// Safely get IP address
if ip := c.IP(); ip != "" {
errorResponse.Details["ip"] = ip
} else {
errorResponse.Details["ip"] = "unknown"
}
}()
}
// Return appropriate response based on status code
if c == nil {
// If context is nil, we can't return a response
return fmt.Errorf("cannot return HTTP response: context is nil")
}
if statusCode >= 500 {
// For server errors, don't expose internal details
return c.Status(statusCode).JSON(ErrorResponse{