29 lines
507 B
Go
29 lines
507 B
Go
package main
|
|
|
|
import (
|
|
// Standard
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
type Request struct {
|
|
ID string
|
|
}
|
|
|
|
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)
|
|
}
|