mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-30 03:12:24 -05:00
[performance] http response encoding / writing improvements (#2374)
This commit is contained in:
parent
d7e35f6bc9
commit
74700cc803
104 changed files with 526 additions and 267 deletions
|
|
@ -266,11 +266,16 @@ func toJSON(a any) string {
|
|||
}
|
||||
a = m
|
||||
}
|
||||
b, err := json.MarshalIndent(a, "", " ")
|
||||
var dst bytes.Buffer
|
||||
enc := json.NewEncoder(&dst)
|
||||
enc.SetIndent("", " ")
|
||||
enc.SetEscapeHTML(false)
|
||||
err := enc.Encode(a)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return string(b)
|
||||
dst.Truncate(dst.Len() - 1) // drop new-line
|
||||
return dst.String()
|
||||
}
|
||||
|
||||
// indentJSON will return indented JSON from raw provided JSON.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue