StarlioX/api/utils/utils.go

19 lines
389 B
Go
Raw Normal View History

2022-09-18 19:28:56 +03:00
package utils
import (
"encoding/json"
"net/http"
)
func Message(status bool, message string) map[string]interface{} {
return map[string]interface{}{"status": status, "message": message}
}
func Respond(w http.ResponseWriter, data map[string]interface{}) {
w.Header().Add("Content-Type", "application/json")
2022-09-19 02:06:28 +03:00
err := json.NewEncoder(w).Encode(data)
if err != nil {
panic(err)
}
2022-09-18 19:28:56 +03:00
}