[performance] http response encoding / writing improvements (#2374)

This commit is contained in:
kim 2023-11-27 14:00:57 +00:00 committed by GitHub
commit 74700cc803
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
104 changed files with 526 additions and 267 deletions

View file

@ -107,7 +107,7 @@ func (m *Module) AccountCreatePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, ti)
apiutil.JSON(c, http.StatusOK, ti)
}
// validateNormalizeCreateAccount checks through all the necessary prerequisites for creating a new account,

View file

@ -96,5 +96,7 @@ func (m *Module) AccountDeletePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusAccepted, gin.H{"message": "accepted"})
apiutil.JSON(c, http.StatusAccepted, map[string]string{
"message": "accepted",
})
}

View file

@ -90,5 +90,5 @@ func (m *Module) AccountGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, acctInfo)
apiutil.JSON(c, http.StatusOK, acctInfo)
}

View file

@ -170,7 +170,7 @@ func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, acctSensitive)
apiutil.JSON(c, http.StatusOK, acctSensitive)
}
// fieldsAttributesFormBinding satisfies gin's binding.Binding interface.

View file

@ -73,5 +73,5 @@ func (m *Module) AccountVerifyGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, acctSensitive)
apiutil.JSON(c, http.StatusOK, acctSensitive)
}

View file

@ -90,5 +90,5 @@ func (m *Module) AccountBlockPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, relationship)
apiutil.JSON(c, http.StatusOK, relationship)
}

View file

@ -122,5 +122,5 @@ func (m *Module) AccountFollowPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, relationship)
apiutil.JSON(c, http.StatusOK, relationship)
}

View file

@ -151,5 +151,5 @@ func (m *Module) AccountFollowersGETHandler(c *gin.Context) {
c.Header("Link", resp.LinkHeader)
}
c.JSON(http.StatusOK, resp.Items)
apiutil.JSON(c, http.StatusOK, resp.Items)
}

View file

@ -151,5 +151,5 @@ func (m *Module) AccountFollowingGETHandler(c *gin.Context) {
c.Header("Link", resp.LinkHeader)
}
c.JSON(http.StatusOK, resp.Items)
apiutil.JSON(c, http.StatusOK, resp.Items)
}

View file

@ -93,5 +93,5 @@ func (m *Module) AccountListsGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, lists)
apiutil.JSON(c, http.StatusOK, lists)
}

View file

@ -89,5 +89,5 @@ func (m *Module) AccountLookupGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, account)
apiutil.JSON(c, http.StatusOK, account)
}

View file

@ -104,5 +104,5 @@ func (m *Module) AccountNotePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, relationship)
apiutil.JSON(c, http.StatusOK, relationship)
}

View file

@ -106,5 +106,5 @@ func (m *Module) AccountRelationshipsGETHandler(c *gin.Context) {
relationships = append(relationships, *r)
}
c.JSON(http.StatusOK, relationships)
apiutil.JSON(c, http.StatusOK, relationships)
}

View file

@ -162,5 +162,5 @@ func (m *Module) AccountSearchGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, results)
apiutil.JSON(c, http.StatusOK, results)
}

View file

@ -241,5 +241,6 @@ func (m *Module) AccountStatusesGETHandler(c *gin.Context) {
if resp.LinkHeader != "" {
c.Header("Link", resp.LinkHeader)
}
c.JSON(http.StatusOK, resp.Items)
apiutil.JSON(c, http.StatusOK, resp.Items)
}

View file

@ -91,5 +91,6 @@ func (m *Module) AccountUnblockPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, relationship)
apiutil.JSON(c, http.StatusOK, relationship)
}

View file

@ -91,5 +91,5 @@ func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, relationship)
apiutil.JSON(c, http.StatusOK, relationship)
}