mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(performance): performance optimizations EE-6042 (#10520)
This commit is contained in:
parent
e4e66dac9c
commit
ae1726cece
71 changed files with 311 additions and 382 deletions
|
@ -2,12 +2,13 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
httperror "github.com/portainer/portainer/pkg/libhttp/error"
|
||||
|
||||
"github.com/segmentio/encoding/json"
|
||||
)
|
||||
|
||||
// JSON encodes data to rw in JSON format. Returns a pointer to a
|
||||
|
@ -15,7 +16,11 @@ import (
|
|||
func JSON(rw http.ResponseWriter, data interface{}) *httperror.HandlerError {
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
|
||||
err := json.NewEncoder(rw).Encode(data)
|
||||
enc := json.NewEncoder(rw)
|
||||
enc.SetSortMapKeys(false)
|
||||
enc.SetAppendNewline(false)
|
||||
|
||||
err := enc.Encode(data)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to write JSON response", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue