pkg/http: Replace interface{} with any

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>
This commit is contained in:
Thomas Hipp 2023-09-26 19:54:22 +02:00
parent 81d15a8436
commit 4e6033896d
No known key found for this signature in database
GPG key ID: 36F3DB891755E09B
3 changed files with 8 additions and 8 deletions

View file

@ -8,11 +8,11 @@ import (
"reflect"
)
func MarshalJSON(w http.ResponseWriter, i interface{}) {
func MarshalJSON(w http.ResponseWriter, i any) {
MarshalJSONWithStatus(w, i, http.StatusOK)
}
func MarshalJSONWithStatus(w http.ResponseWriter, i interface{}, status int) {
func MarshalJSONWithStatus(w http.ResponseWriter, i any, status int) {
w.Header().Set("content-type", "application/json")
w.WriteHeader(status)
if i == nil || (reflect.ValueOf(i).Kind() == reflect.Ptr && reflect.ValueOf(i).IsNil()) {