16 lines
396 B
Go
16 lines
396 B
Go
package main
|
|
|
|
import (
|
|
"git.gammaspectra.live/P2Pool/consensus/v4/utils"
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func EncodeJson(r *http.Request, writer io.Writer, d any) error {
|
|
encoder := utils.NewJSONEncoder(writer)
|
|
if strings.Index(strings.ToLower(r.Header.Get("user-agent")), "mozilla") != -1 {
|
|
encoder.SetIndent("", " ")
|
|
}
|
|
return encoder.EncodeWithOption(d, utils.JsonEncodeOptions...)
|
|
}
|