mirror of
https://github.com/nkanaev/yarr.git
synced 2025-12-15 08:37:21 +00:00
refactoring
This commit is contained in:
17
server/response.go
Normal file
17
server/response.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"log"
|
||||
)
|
||||
|
||||
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"))
|
||||
}
|
||||
Reference in New Issue
Block a user