[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)
}

View file

@ -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",
})
}

View file

@ -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 {

View file

@ -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)
}

View file

@ -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",
})
}

View file

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

View file

@ -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 {

View file

@ -105,5 +105,5 @@ func (m *Module) EmojiDELETEHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, emoji)
apiutil.JSON(c, http.StatusOK, emoji)
}

View file

@ -95,5 +95,5 @@ func (m *Module) EmojiGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, emoji)
apiutil.JSON(c, http.StatusOK, emoji)
}

View file

@ -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)
}

View file

@ -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

View file

@ -102,5 +102,5 @@ func (m *Module) MediaCleanupPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, remoteCacheDays)
apiutil.JSON(c, http.StatusOK, remoteCacheDays)
}

View file

@ -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)
}

View file

@ -98,5 +98,5 @@ func (m *Module) ReportGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, report)
apiutil.JSON(c, http.StatusOK, report)
}

View file

@ -120,5 +120,5 @@ func (m *Module) ReportResolvePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, report)
apiutil.JSON(c, http.StatusOK, report)
}

View file

@ -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)
}

View file

@ -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 {

View file

@ -103,5 +103,5 @@ func (m *Module) RuleDELETEHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, apiRule)
apiutil.JSON(c, http.StatusOK, apiRule)
}

View file

@ -98,5 +98,5 @@ func (m *Module) RuleGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, rule)
apiutil.JSON(c, http.StatusOK, rule)
}

View file

@ -87,5 +87,5 @@ func (m *Module) RulesGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, resp)
apiutil.JSON(c, http.StatusOK, resp)
}

View file

@ -123,5 +123,5 @@ func (m *Module) RulePATCHHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, apiRule)
apiutil.JSON(c, http.StatusOK, apiRule)
}

View file

@ -121,5 +121,5 @@ func (m *Module) AppsPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, apiApp)
apiutil.JSON(c, http.StatusOK, apiApp)
}

View file

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

View file

@ -120,5 +120,6 @@ func (m *Module) BookmarksGETHandler(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

@ -71,5 +71,5 @@ func (m *Module) CustomEmojisGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, emojis)
apiutil.JSON(c, http.StatusOK, emojis)
}

View file

@ -137,5 +137,6 @@ func (m *Module) FavouritesGETHandler(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

@ -71,5 +71,5 @@ func (m *Module) FeaturedTagsGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, []interface{}{})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
}

View file

@ -38,5 +38,5 @@ func (m *Module) FiltersGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, []string{})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray)
}

View file

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

View file

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

View file

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

View file

@ -58,7 +58,7 @@ func (m *Module) InstanceInformationGETHandlerV1(c *gin.Context) {
return
}
c.JSON(http.StatusOK, instance)
apiutil.JSON(c, http.StatusOK, instance)
}
// InstanceInformationGETHandlerV2 swagger:operation GET /api/v2/instance instanceGetV2
@ -93,5 +93,5 @@ func (m *Module) InstanceInformationGETHandlerV2(c *gin.Context) {
return
}
c.JSON(http.StatusOK, instance)
apiutil.JSON(c, http.StatusOK, instance)
}

View file

@ -161,7 +161,7 @@ func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, i)
apiutil.JSON(c, http.StatusOK, i)
}
func validateInstanceUpdate(form *apimodel.InstanceSettingsUpdateRequest) error {

View file

@ -78,8 +78,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() {
"uri": "http://localhost:8080",
"account_domain": "localhost:8080",
"title": "Example Instance",
"description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"email": "someone@example.org",
"version": "0.0.0-testrig",
"languages": [
@ -195,8 +195,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() {
"uri": "http://localhost:8080",
"account_domain": "localhost:8080",
"title": "Geoff's Instance",
"description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"email": "admin@example.org",
"version": "0.0.0-testrig",
"languages": [
@ -312,8 +312,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() {
"uri": "http://localhost:8080",
"account_domain": "localhost:8080",
"title": "GoToSocial Testrig Instance",
"description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"short_description": "\u003cp\u003eThis is some html, which is \u003cem\u003eallowed\u003c/em\u003e in short descriptions.\u003c/p\u003e",
"description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"short_description": "<p>This is some html, which is <em>allowed</em> in short descriptions.</p>",
"email": "admin@example.org",
"version": "0.0.0-testrig",
"languages": [
@ -480,8 +480,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() {
"uri": "http://localhost:8080",
"account_domain": "localhost:8080",
"title": "GoToSocial Testrig Instance",
"description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"email": "",
"version": "0.0.0-testrig",
"languages": [
@ -619,8 +619,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
"uri": "http://localhost:8080",
"account_domain": "localhost:8080",
"title": "GoToSocial Testrig Instance",
"description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"email": "admin@example.org",
"version": "0.0.0-testrig",
"languages": [
@ -773,8 +773,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() {
"uri": "http://localhost:8080",
"account_domain": "localhost:8080",
"title": "GoToSocial Testrig Instance",
"description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"short_description": "<p>This is the GoToSocial testrig. It doesn't federate or anything.</p><p>When the testrig is shut down, all data on it will be deleted.</p><p>Don't use this in production!</p>",
"email": "admin@example.org",
"version": "0.0.0-testrig",
"languages": [

View file

@ -156,5 +156,5 @@ func (m *Module) InstancePeersGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, data)
apiutil.JSON(c, http.StatusOK, data)
}

View file

@ -67,5 +67,5 @@ func (m *Module) InstanceRulesGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, resp)
apiutil.JSON(c, http.StatusOK, resp)
}

View file

@ -174,5 +174,6 @@ func (m *Module) ListAccountsGETHandler(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

@ -116,5 +116,5 @@ func (m *Module) ListAccountsPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, gin.H{})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject)
}

View file

@ -126,5 +126,5 @@ func (m *Module) ListAccountsDELETEHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, gin.H{})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject)
}

View file

@ -102,5 +102,5 @@ func (m *Module) ListCreatePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, apiList)
apiutil.JSON(c, http.StatusOK, apiList)
}

View file

@ -87,5 +87,5 @@ func (m *Module) ListDELETEHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, gin.H{})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject)
}

View file

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

View file

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

View file

@ -148,5 +148,5 @@ func (m *Module) ListUpdatePUTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, apiList)
apiutil.JSON(c, http.StatusOK, apiList)
}

View file

@ -84,7 +84,7 @@ func (m *Module) MarkersGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, marker)
apiutil.JSON(c, http.StatusOK, marker)
}
// parseMarkerNames turns a list of strings into a set of valid marker timeline names, or returns an error.

View file

@ -106,5 +106,5 @@ func (m *Module) MarkersPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, marker)
apiutil.JSON(c, http.StatusOK, marker)
}

View file

@ -139,7 +139,7 @@ func (m *Module) MediaCreatePOSTHandler(c *gin.Context) {
apiAttachment.URL = nil
}
c.JSON(http.StatusOK, apiAttachment)
apiutil.JSON(c, http.StatusOK, apiAttachment)
}
func validateCreateMedia(form *apimodel.AttachmentRequest) error {

View file

@ -98,5 +98,5 @@ func (m *Module) MediaGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, attachment)
apiutil.JSON(c, http.StatusOK, attachment)
}

View file

@ -141,7 +141,7 @@ func (m *Module) MediaPUTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, attachment)
apiutil.JSON(c, http.StatusOK, attachment)
}
func validateUpdateMedia(form *apimodel.AttachmentUpdateRequest) error {

View file

@ -83,5 +83,5 @@ func (m *Module) NotificationGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, resp)
apiutil.JSON(c, http.StatusOK, resp)
}

View file

@ -75,5 +75,5 @@ func (m *Module) NotificationsClearPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, struct{}{})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONObject)
}

View file

@ -155,5 +155,6 @@ func (m *Module) NotificationsGETHandler(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

@ -96,5 +96,5 @@ func (m *Module) PollGETHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, poll)
apiutil.JSON(c, http.StatusOK, poll)
}

View file

@ -117,7 +117,7 @@ func (m *Module) PollVotePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, poll)
apiutil.JSON(c, http.StatusOK, poll)
}
func bindChoices(c *gin.Context) ([]int, error) {

View file

@ -87,5 +87,6 @@ func (m *Module) PreferencesGETHandler(c *gin.Context) {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return
}
c.JSON(http.StatusOK, resp)
apiutil.JSON(c, http.StatusOK, resp)
}

View file

@ -107,5 +107,5 @@ func (m *Module) ReportPOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, apiReport)
apiutil.JSON(c, http.StatusOK, apiReport)
}

View file

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

View file

@ -168,5 +168,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)
}

View file

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

View file

@ -147,5 +147,6 @@ func (m *Module) HomeTimelineGETHandler(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

@ -145,5 +145,6 @@ func (m *Module) ListTimelineGETHandler(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

@ -158,5 +158,6 @@ func (m *Module) PublicTimelineGETHandler(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

@ -142,5 +142,6 @@ func (m *Module) TagTimelineGETHandler(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

@ -99,5 +99,5 @@ func (m *Module) PasswordChangePOSTHandler(c *gin.Context) {
return
}
c.JSON(http.StatusOK, gin.H{"status": "OK"})
apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.StatusOKJSON)
}