mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 00:02:25 -05:00
[performance] http response encoding / writing improvements (#2374)
This commit is contained in:
parent
d7e35f6bc9
commit
74700cc803
104 changed files with 526 additions and 267 deletions
|
|
@ -124,5 +124,7 @@ func (m *Module) AccountActionPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "OK"})
|
||||
apiutil.JSON(c, http.StatusOK, map[string]string{
|
||||
"message": "OK",
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,9 @@ func (m *Module) DomainKeysExpirePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusAccepted, &apimodel.AdminActionResponse{ActionID: actionID})
|
||||
apiutil.JSON(c, http.StatusOK, &apimodel.AdminActionResponse{
|
||||
ActionID: actionID,
|
||||
})
|
||||
}
|
||||
|
||||
func validateDomainKeysExpire(form *apimodel.DomainKeysExpireRequest) error {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ func (m *Module) createDomainPermissions(
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, domainBlock)
|
||||
apiutil.JSON(c, http.StatusOK, domainBlock)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ func (m *Module) createDomainPermissions(
|
|||
domainPerms = append(domainPerms, entry.Resource)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, domainPerms)
|
||||
apiutil.JSON(c, http.StatusOK, domainPerms)
|
||||
}
|
||||
|
||||
// deleteDomainPermission deletes a single domain permission (block or allow).
|
||||
|
|
@ -200,7 +200,7 @@ func (m *Module) deleteDomainPermission(
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, domainPerm)
|
||||
apiutil.JSON(c, http.StatusOK, domainPerm)
|
||||
}
|
||||
|
||||
// getDomainPermission gets a single domain permission (block or allow).
|
||||
|
|
@ -248,7 +248,7 @@ func (m *Module) getDomainPermission(
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, domainPerm)
|
||||
apiutil.JSON(c, http.StatusOK, domainPerm)
|
||||
}
|
||||
|
||||
// getDomainPermissions gets all domain permissions of the given type (block, allow).
|
||||
|
|
@ -290,5 +290,5 @@ func (m *Module) getDomainPermissions(
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, domainPerm)
|
||||
apiutil.JSON(c, http.StatusOK, domainPerm)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,5 +116,7 @@ func (m *Module) EmailTestPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusAccepted, gin.H{"status": "test email sent"})
|
||||
apiutil.JSON(c, http.StatusAccepted, map[string]string{
|
||||
"status": "test email sent",
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,5 +89,5 @@ func (m *Module) EmojiCategoriesGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, categories)
|
||||
apiutil.JSON(c, http.StatusOK, categories)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (m *Module) EmojiCreatePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, apiEmoji)
|
||||
apiutil.JSON(c, http.StatusOK, apiEmoji)
|
||||
}
|
||||
|
||||
func validateCreateEmoji(form *apimodel.EmojiCreateRequest) error {
|
||||
|
|
|
|||
|
|
@ -105,5 +105,5 @@ func (m *Module) EmojiDELETEHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, emoji)
|
||||
apiutil.JSON(c, http.StatusOK, emoji)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,5 +95,5 @@ func (m *Module) EmojiGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, emoji)
|
||||
apiutil.JSON(c, http.StatusOK, emoji)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,5 +206,6 @@ func (m *Module) EmojisGETHandler(c *gin.Context) {
|
|||
if resp.LinkHeader != "" {
|
||||
c.Header("Link", resp.LinkHeader)
|
||||
}
|
||||
c.JSON(http.StatusOK, resp.Items)
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, resp.Items)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ func (m *Module) EmojiPATCHHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, emoji)
|
||||
apiutil.JSON(c, http.StatusOK, emoji)
|
||||
}
|
||||
|
||||
// do a first pass on the form here
|
||||
|
|
|
|||
|
|
@ -102,5 +102,5 @@ func (m *Module) MediaCleanupPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, remoteCacheDays)
|
||||
apiutil.JSON(c, http.StatusOK, remoteCacheDays)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,5 +88,5 @@ func (m *Module) MediaRefetchPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.Status(http.StatusAccepted)
|
||||
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.StatusAcceptedJSON)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,5 +98,5 @@ func (m *Module) ReportGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, report)
|
||||
apiutil.JSON(c, http.StatusOK, report)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,5 +120,5 @@ func (m *Module) ReportResolvePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, report)
|
||||
apiutil.JSON(c, http.StatusOK, report)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,5 +176,6 @@ func (m *Module) ReportsGETHandler(c *gin.Context) {
|
|||
if resp.LinkHeader != "" {
|
||||
c.Header("Link", resp.LinkHeader)
|
||||
}
|
||||
c.JSON(http.StatusOK, resp.Items)
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, resp.Items)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ func (m *Module) RulePOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, apiRule)
|
||||
apiutil.JSON(c, http.StatusOK, apiRule)
|
||||
}
|
||||
|
||||
func validateCreateRule(form *apimodel.InstanceRuleCreateRequest) error {
|
||||
|
|
|
|||
|
|
@ -103,5 +103,5 @@ func (m *Module) RuleDELETEHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, apiRule)
|
||||
apiutil.JSON(c, http.StatusOK, apiRule)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,5 +98,5 @@ func (m *Module) RuleGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, rule)
|
||||
apiutil.JSON(c, http.StatusOK, rule)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,5 +87,5 @@ func (m *Module) RulesGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
apiutil.JSON(c, http.StatusOK, resp)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,5 +123,5 @@ func (m *Module) RulePATCHHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, apiRule)
|
||||
apiutil.JSON(c, http.StatusOK, apiRule)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue