rewritten from net/http to fiber, changed port from 8080, 4662 to one 3000

This commit is contained in:
Данил 2022-10-23 15:26:51 +03:00
parent 42f568cf85
commit 16301a3428
8 changed files with 102 additions and 47 deletions

View file

@ -2,17 +2,18 @@ package utils
import (
"encoding/json"
"github.com/Redume/EveryNasa/functions"
"net/http"
"github.com/gofiber/fiber/v2"
)
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")
err := json.NewEncoder(w).Encode(data)
func Respond(c *fiber.Ctx, data map[string]interface{}) {
c.Set("Content-Type", "application/json")
err := json.NewEncoder(c).Encode(data)
if err != nil {
functions.Logger(err.Error())
}