This commit is contained in:
Magnus Åhall 2023-06-15 14:12:35 +02:00
parent 79288b0483
commit b8a673fb0a
7 changed files with 148 additions and 29 deletions

View file

@ -3,10 +3,26 @@ package main
import (
// Standard
"encoding/json"
"net/http"
)
type Request struct {
ID string
}
func (req *Request)
func responseError(w http.ResponseWriter, err error) {
res := map[string]interface{}{
"ok": false,
"error": err.Error(),
}
resJSON, _ := json.Marshal(res)
w.Header().Add("Content-Type", "application/json")
w.Write(resJSON)
}
func responseData(w http.ResponseWriter, data interface{}) {
resJSON, _ := json.Marshal(data)
w.Header().Add("Content-Type", "application/json")
w.Write(resJSON)
}