diff --git a/internal/controller/http/v1/sync.go b/internal/controller/http/v1/sync.go index d3bb83d..09e433d 100644 --- a/internal/controller/http/v1/sync.go +++ b/internal/controller/http/v1/sync.go @@ -28,7 +28,7 @@ func (r *syncRoutes) updateProgress(c *gin.Context) { var doc entity.Progress if err := c.ShouldBindJSON(&doc); err != nil { r.l.Error(err) - c.JSON(http.StatusBadRequest, gin.H{"message": "Bad request", "code": 4000}) + c.AsciiJSON(http.StatusBadRequest, gin.H{"message": "Bad request", "code": 4000}) return } @@ -36,20 +36,20 @@ func (r *syncRoutes) updateProgress(c *gin.Context) { savedDoc, err := r.progress.Sync(c, doc) if err != nil { r.l.Error(err) - c.JSON(http.StatusInternalServerError, gin.H{"message": "Internal server error", "code": 5000}) + c.AsciiJSON(http.StatusInternalServerError, gin.H{"message": "Internal server error", "code": 5000}) return } - c.JSON(http.StatusOK, gin.H{"timestamp": savedDoc.Timestamp, "document": savedDoc}) + c.AsciiJSON(http.StatusOK, gin.H{"timestamp": savedDoc.Timestamp, "document": savedDoc}) } func (r *syncRoutes) fetchProgress(c *gin.Context) { doc, err := r.progress.Fetch(c, c.Param("document")) if err != nil { r.l.Error(err) - c.JSON(http.StatusInternalServerError, gin.H{"message": "Internal server error", "code": 5000}) + c.AsciiJSON(http.StatusInternalServerError, gin.H{"message": "Internal server error", "code": 5000}) return } - c.JSON(http.StatusOK, doc) + c.AsciiJSON(http.StatusOK, doc) } diff --git a/internal/controller/http/v1/users.go b/internal/controller/http/v1/users.go index aa1df3f..eb70b83 100644 --- a/internal/controller/http/v1/users.go +++ b/internal/controller/http/v1/users.go @@ -25,7 +25,7 @@ func newUserRoutes(handler *gin.RouterGroup, a auth.AuthInterface, l logger.Inte func (r *userRoutes) authenicate(c *gin.Context) { // authenication done by authDeviceMiddleware - c.JSON(http.StatusOK, gin.H{"message": "OK", "code": 200}) + c.AsciiJSON(http.StatusOK, gin.H{"message": "OK", "code": 200}) } func authDeviceMiddleware(auth auth.AuthInterface, l logger.Interface) gin.HandlerFunc { @@ -33,12 +33,12 @@ func authDeviceMiddleware(auth auth.AuthInterface, l logger.Interface) gin.Handl username := c.GetHeader("x-auth-user") hashed_password := c.GetHeader("x-auth-key") if username == "" || hashed_password == "" { - c.JSON(http.StatusUnauthorized, gin.H{"message": "Unauthorized", "code": 2001}) + c.AsciiJSON(http.StatusUnauthorized, gin.H{"message": "Unauthorized", "code": 2001}) c.Abort() return } if !auth.CheckDevicePassword(c.Request.Context(), username, hashed_password, false) { - c.JSON(http.StatusUnauthorized, gin.H{"message": "Unauthorized", "code": 2001}) + c.AsciiJSON(http.StatusUnauthorized, gin.H{"message": "Unauthorized", "code": 2001}) c.Abort() return }