aboutsummaryrefslogtreecommitdiffstats
path: root/services/lfs
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-07-25 00:03:58 +0800
committerGitHub <noreply@github.com>2021-07-24 18:03:58 +0200
commit9f31f3aa8ac4f6bfc8390c9ae63b2a387b414c88 (patch)
tree6f27dc68a35d1f9d806c632e36f0edc8543184ea /services/lfs
parente0f9635c0691cb67f0fcbb758cabba801d9fc51b (diff)
downloadgitea-9f31f3aa8ac4f6bfc8390c9ae63b2a387b414c88.tar.gz
gitea-9f31f3aa8ac4f6bfc8390c9ae63b2a387b414c88.zip
Add an abstract json layout to make it's easier to change json library (#16528)
* Add an abstract json layout to make it's easier to change json library * Fix import * Fix import sequence * Fix blank lines * Fix blank lines
Diffstat (limited to 'services/lfs')
-rw-r--r--services/lfs/locks.go6
-rw-r--r--services/lfs/server.go8
2 files changed, 7 insertions, 7 deletions
diff --git a/services/lfs/locks.go b/services/lfs/locks.go
index 20ba12e65b..641c1c595b 100644
--- a/services/lfs/locks.go
+++ b/services/lfs/locks.go
@@ -12,11 +12,11 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
+ "code.gitea.io/gitea/modules/json"
lfs_module "code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
- jsoniter "github.com/json-iterator/go"
)
func handleLockListOut(ctx *context.Context, repo *models.Repository, lock *models.LFSLock, err error) {
@@ -159,7 +159,7 @@ func PostLockHandler(ctx *context.Context) {
var req api.LFSLockRequest
bodyReader := ctx.Req.Body
defer bodyReader.Close()
- json := jsoniter.ConfigCompatibleWithStandardLibrary
+
dec := json.NewDecoder(bodyReader)
if err := dec.Decode(&req); err != nil {
log.Warn("Failed to decode lock request as json. Error: %v", err)
@@ -293,7 +293,7 @@ func UnLockHandler(ctx *context.Context) {
var req api.LFSLockDeleteRequest
bodyReader := ctx.Req.Body
defer bodyReader.Close()
- json := jsoniter.ConfigCompatibleWithStandardLibrary
+
dec := json.NewDecoder(bodyReader)
if err := dec.Decode(&req); err != nil {
log.Warn("Failed to decode lock request as json. Error: %v", err)
diff --git a/services/lfs/server.go b/services/lfs/server.go
index 6b79a3a364..0d357939d5 100644
--- a/services/lfs/server.go
+++ b/services/lfs/server.go
@@ -17,12 +17,12 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/json"
lfs_module "code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/golang-jwt/jwt"
- jsoniter "github.com/json-iterator/go"
)
// requestContext contain variables from the HTTP request.
@@ -243,7 +243,7 @@ func BatchHandler(ctx *context.Context) {
ctx.Resp.Header().Set("Content-Type", lfs_module.MediaType)
- enc := jsoniter.NewEncoder(ctx.Resp)
+ enc := json.NewEncoder(ctx.Resp)
if err := enc.Encode(respobj); err != nil {
log.Error("Failed to encode representation as json. Error: %v", err)
}
@@ -336,7 +336,7 @@ func VerifyHandler(ctx *context.Context) {
func decodeJSON(req *http.Request, v interface{}) error {
defer req.Body.Close()
- dec := jsoniter.NewDecoder(req.Body)
+ dec := json.NewDecoder(req.Body)
return dec.Decode(v)
}
@@ -429,7 +429,7 @@ func writeStatusMessage(ctx *context.Context, status int, message string) {
er := lfs_module.ErrorResponse{Message: message}
- enc := jsoniter.NewEncoder(ctx.Resp)
+ enc := json.NewEncoder(ctx.Resp)
if err := enc.Encode(er); err != nil {
log.Error("Failed to encode error response as json. Error: %v", err)
}