add other functions

This commit is contained in:
Данил 2022-09-18 19:28:56 +03:00
parent 41a46c7c6c
commit 1370774f6d
3 changed files with 163 additions and 0 deletions

15
api/utils/utils.go Normal file
View file

@ -0,0 +1,15 @@
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")
json.NewEncoder(w).Encode(data)
}