small fix, don't worry about it

This commit is contained in:
Tomas Dvorak
2026-04-10 12:06:24 +02:00
commit 5c500a72b0
243 changed files with 44176 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package httpx
import "github.com/gin-gonic/gin"
type ErrorResponse struct {
Error string `json:"error"`
RequestID string `json:"requestId,omitempty"`
}
func JSONError(c *gin.Context, status int, message string) {
requestID, _ := c.Get("request_id")
c.JSON(status, ErrorResponse{
Error: message,
RequestID: toString(requestID),
})
}
func JSON(c *gin.Context, status int, payload any) {
c.JSON(status, payload)
}
func toString(value any) string {
if value == nil {
return ""
}
typed, ok := value.(string)
if !ok {
return ""
}
return typed
}
+21
View File
@@ -0,0 +1,21 @@
package logger
import "go.uber.org/zap"
func New(env string) *zap.Logger {
if env == "production" {
log, err := zap.NewProduction()
if err == nil {
return log
}
}
config := zap.NewDevelopmentConfig()
config.EncoderConfig.TimeKey = "ts"
log, err := config.Build()
if err != nil {
return zap.Must(zap.NewDevelopment())
}
return log
}