File tree Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Expand file tree Collapse file tree 3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 5
5
require (
6
6
github.com/go-chi/chi/v5 v5.0.10
7
7
github.com/go-chi/cors v1.2.1
8
+ github.com/go-json-experiment/json v0.0.0-20230922184908-dc36ffcf8533
8
9
github.com/go-logr/logr v1.2.4
9
10
github.com/go-logr/zapr v1.2.4
10
11
github.com/golang-jwt/jwt v3.2.2+incompatible
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
11
11
github.com/go-chi/chi/v5 v5.0.10 /go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8 =
12
12
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4 =
13
13
github.com/go-chi/cors v1.2.1 /go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58 =
14
+ github.com/go-json-experiment/json v0.0.0-20230922184908-dc36ffcf8533 h1:1SRqDZauC9fz6vMIDLCUOULPNfOnZ0rmvZo8quraoy4 =
15
+ github.com/go-json-experiment/json v0.0.0-20230922184908-dc36ffcf8533 /go.mod h1:6daplAwHHGbUGib4990V3Il26O0OC4aRyvewaaAihaA =
14
16
github.com/go-logr/logr v1.2.0 /go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A =
15
17
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ =
16
18
github.com/go-logr/logr v1.2.4 /go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A =
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package main
2
2
3
3
import (
4
4
"context"
5
- "encoding/json"
6
5
"errors"
7
6
"fmt"
8
7
"net/http"
@@ -14,6 +13,7 @@ import (
14
13
"github.com/go-chi/chi/v5"
15
14
"github.com/go-chi/chi/v5/middleware"
16
15
"github.com/go-chi/cors"
16
+ "github.com/go-json-experiment/json"
17
17
"github.com/go-logr/logr"
18
18
"github.com/jmoiron/sqlx"
19
19
"github.com/spf13/cobra"
@@ -151,8 +151,7 @@ func (server *dbServer) responseError(w http.ResponseWriter, err error) {
151
151
func (server * dbServer ) responseData (w http.ResponseWriter , data interface {}, statusCode int ) {
152
152
w .WriteHeader (statusCode )
153
153
154
- enc := json .NewEncoder (w )
155
- if encodeErr := enc .Encode (data ); encodeErr != nil {
154
+ if encodeErr := json .MarshalWrite (w , data ); encodeErr != nil {
156
155
server .logger .Error (encodeErr , "failed to write response" )
157
156
w .WriteHeader (http .StatusInternalServerError )
158
157
return
You can’t perform that action at this time.
0 commit comments