diff options
author | zeripath <art27@cantab.net> | 2021-03-01 21:08:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 22:08:10 +0100 |
commit | f0e15250b9e322cc7731ba026d12387c2b549a42 (patch) | |
tree | f13d46119077ba924d620ef172b91daa315bda0a /routers/repo | |
parent | 59fd641d1fb021e35aea7f9f4a1916cc11ef5c51 (diff) | |
download | gitea-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 'routers/repo')
-rw-r--r-- | routers/repo/editor.go | 3 | ||||
-rw-r--r-- | routers/repo/webhook.go | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 344174828e..14a75556d2 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -5,7 +5,6 @@ package repo import ( - "encoding/json" "fmt" "io/ioutil" "path" @@ -25,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/utils" + jsoniter "github.com/json-iterator/go" ) const ( @@ -158,6 +158,7 @@ func GetEditorConfig(ctx *context.Context, treePath string) string { if err == nil { def, err := ec.GetDefinitionForFilename(treePath) if err == nil { + json := jsoniter.ConfigCompatibleWithStandardLibrary jsonStr, _ := json.Marshal(def) return string(jsonStr) } diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 01d142843f..d1d4dc0208 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -6,7 +6,6 @@ package repo import ( - "encoding/json" "errors" "fmt" "path" @@ -23,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/webhook" + jsoniter "github.com/json-iterator/go" ) const ( @@ -305,6 +305,7 @@ func DiscordHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.DiscordMeta{ Username: form.Username, IconURL: form.IconURL, @@ -400,6 +401,7 @@ func TelegramHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.TelegramMeta{ BotToken: form.BotToken, ChatID: form.ChatID, @@ -452,6 +454,7 @@ func MatrixHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.MatrixMeta{ HomeserverURL: form.HomeserverURL, Room: form.RoomID, @@ -556,6 +559,7 @@ func SlackHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.SlackMeta{ Channel: strings.TrimSpace(form.Channel), Username: form.Username, @@ -799,6 +803,7 @@ func SlackHooksEditPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.SlackMeta{ Channel: strings.TrimSpace(form.Channel), Username: form.Username, @@ -844,6 +849,7 @@ func DiscordHooksEditPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.DiscordMeta{ Username: form.Username, IconURL: form.IconURL, @@ -919,6 +925,7 @@ func TelegramHooksEditPost(ctx *context.Context) { ctx.HTML(200, orCtx.NewTemplate) return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.TelegramMeta{ BotToken: form.BotToken, ChatID: form.ChatID, @@ -960,6 +967,7 @@ func MatrixHooksEditPost(ctx *context.Context) { ctx.HTML(200, orCtx.NewTemplate) return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.MatrixMeta{ HomeserverURL: form.HomeserverURL, Room: form.RoomID, |