first commit

This commit is contained in:
kandrusyak
2023-07-14 14:54:41 +03:00
commit 7b03922374
29 changed files with 839 additions and 0 deletions

33
services/users.go Normal file
View File

@@ -0,0 +1,33 @@
package services
import (
"astra-events/config"
"astra-events/model"
"astra-events/pkg/api"
"encoding/json"
"errors"
"net/http"
"strconv"
)
func GetUser(ID uint, header http.Header) (*model.User, error) {
id := strconv.Itoa(int(ID))
data, err, _ := api.GetRequest(
config.Env.MSHosts.UsersHost+"/"+id,
header)
if err != nil {
return nil, errors.New("Error Request to Users Service")
}
u := new(model.User)
err = json.Unmarshal(data, &u)
if err != nil {
return nil, errors.New("Bad Response from Users Service")
}
return u, nil
}