chore: 删除未使用的孤立包
清理以下未导入的包: - internal/response (未使用的响应结构体) - pkg/response (未使用的响应封装) - internal/model (TLSFingerprintProfile, ErrorPassthroughRule) - internal/models (SocialAccount, domain已有) - internal/pkg/response (未使用的响应封装) - internal/security/ratelimit (已迁移到middleware) 验证: go build ./... && go test ./... 通过
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Response 统一响应结构
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// Success 成功响应
|
||||
func Success(c *gin.Context, data interface{}) {
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Code: 0,
|
||||
Message: "success",
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// Error 错误响应
|
||||
func Error(c *gin.Context, httpStatus int, message string, err error) {
|
||||
if err != nil {
|
||||
// 在开发环境下返回详细错误信息
|
||||
if gin.Mode() == gin.DebugMode {
|
||||
c.JSON(httpStatus, Response{
|
||||
Code: httpStatus,
|
||||
Message: message,
|
||||
Data: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(httpStatus, Response{
|
||||
Code: httpStatus,
|
||||
Message: message,
|
||||
})
|
||||
}
|
||||
|
||||
// ErrorWithCode 错误响应(带自定义错误码)
|
||||
func ErrorWithCode(c *gin.Context, code int, message string) {
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Code: code,
|
||||
Message: message,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user