Files
godoxy-yusing/src/api/v1/utils/utils.go
2024-08-01 10:06:42 +08:00

18 lines
266 B
Go

package utils
import (
"encoding/json"
"net/http"
)
func RespondJson(data any, w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
j, err := json.Marshal(data)
if err != nil {
return err
} else {
w.Write(j)
}
return nil
}