Files
zeekay ea80dc3638 feat: Add new Dockerfiles and improve containerization
- Add main Dockerfile for production builds
- Add Dockerfile.runtime for secure code execution
- Add Dockerfile.runtime.fixed with improved configuration
- Include .dockerignore for build optimization
- Add integration documentation and publishing guides
- Update API and CLI components for better runtime support
- Enhance sandbox and container management features
2025-08-16 23:03:39 -05:00

36 lines
746 B
Go

// Copyright 2025 Hanzo Industries Inc.
// SPDX-License-Identifier: AGPL-3.0
package middlewares
import (
"net/http"
"time"
"github.com/hanzoai/daemon/pkg/common"
"github.com/gin-gonic/gin"
)
func ErrorMiddleware() gin.HandlerFunc {
return func(ctx *gin.Context) {
ctx.Next()
if len(ctx.Errors) > 0 {
err := ctx.Errors.Last()
statusCode := ctx.Writer.Status()
errorResponse := common.ErrorResponse{
StatusCode: statusCode,
Message: err.Error(),
Code: http.StatusText(statusCode),
Timestamp: time.Now(),
Path: ctx.Request.URL.Path,
Method: ctx.Request.Method,
}
ctx.Header("Content-Type", "application/json")
ctx.AbortWithStatusJSON(statusCode, errorResponse)
}
}
}