mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 21:19:19 +00:00
18 lines
305 B
Go
18 lines
305 B
Go
package server
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func writeJSON(rw http.ResponseWriter, data interface{}) {
|
|
rw.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
reply, err := json.Marshal(data)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
rw.Write(reply)
|
|
rw.Write([]byte("\n"))
|
|
}
|