aboutsummaryrefslogtreecommitdiffstats
path: root/models/webhook.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-01 21:08:10 +0000
committerGitHub <noreply@github.com>2021-03-01 22:08:10 +0100
commitf0e15250b9e322cc7731ba026d12387c2b549a42 (patch)
treef13d46119077ba924d620ef172b91daa315bda0a /models/webhook.go
parent59fd641d1fb021e35aea7f9f4a1916cc11ef5c51 (diff)
downloadgitea-f0e15250b9e322cc7731ba026d12387c2b549a42.tar.gz
gitea-f0e15250b9e322cc7731ba026d12387c2b549a42.zip
Migrate to use jsoniter instead of encoding/json (#14841)
* Migrate to use jsoniter * fix tests * update gitea.com/go-chi/binding Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/models/webhook.go b/models/webhook.go
index c7fcfba49e..9ad01f1b9d 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -7,7 +7,6 @@ package models
import (
"context"
- "encoding/json"
"fmt"
"strings"
"time"
@@ -18,6 +17,7 @@ import (
"code.gitea.io/gitea/modules/timeutil"
gouuid "github.com/google/uuid"
+ jsoniter "github.com/json-iterator/go"
)
// HookContentType is the content type of a web hook
@@ -145,6 +145,8 @@ type Webhook struct {
// AfterLoad updates the webhook object upon setting a column
func (w *Webhook) AfterLoad() {
w.HookEvent = &HookEvent{}
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
log.Error("Unmarshal[%d]: %v", w.ID, err)
}
@@ -157,6 +159,7 @@ func (w *Webhook) History(page int) ([]*HookTask, error) {
// UpdateEvent handles conversion from HookEvent to Events.
func (w *Webhook) UpdateEvent() error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.Marshal(w.HookEvent)
w.Events = string(data)
return err
@@ -689,6 +692,7 @@ func (t *HookTask) AfterLoad() {
}
t.RequestInfo = &HookRequest{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
log.Error("Unmarshal RequestContent[%d]: %v", t.ID, err)
}
@@ -702,6 +706,7 @@ func (t *HookTask) AfterLoad() {
}
func (t *HookTask) simpleMarshalJSON(v interface{}) string {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
p, err := json.Marshal(v)
if err != nil {
log.Error("Marshal [%d]: %v", t.ID, err)