mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- 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
36 lines
746 B
Go
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)
|
|
}
|
|
}
|
|
}
|