mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-17 23:03:49 +01:00
18 lines
266 B
Go
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
|
|
}
|