Starlio-web/api/controllers/version.go
2022-09-25 11:04:32 +03:00

26 lines
508 B
Go

package controllers
import (
"net/http"
"os"
"github.com/Redume/EveryNasa/api/utils"
"github.com/Redume/EveryNasa/functions"
"gopkg.in/yaml.v2"
)
var Version = func(w http.ResponseWriter, r *http.Request) {
file, err := os.ReadFile("config.yaml")
if err != nil {
functions.Logger(err.Error())
}
data := make(map[interface{}]interface{})
err = yaml.Unmarshal(file, &data)
if err != nil {
functions.Logger(err.Error())
}
utils.Respond(w, utils.Message(true, data["version"].(string)))
}