add personal information service

This commit is contained in:
andrusyakka
2023-07-24 16:00:56 +03:00
parent fdc25b46fb
commit f01ac2e42a
3 changed files with 61 additions and 6 deletions

View File

@@ -0,0 +1,47 @@
package personal_information
import (
"astra-api-gateway/config"
"astra-api-gateway/pkg/api"
"github.com/labstack/echo/v4"
"net/http"
)
func GetPDList(c echo.Context) error {
data, err, resp := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/persons/",
c.Request().Header, c.Request().URL.RawQuery)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func GetPD(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/persons/"+id,
c.Request().Header, c.Request().URL.RawQuery)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func CreatePD(c echo.Context) error {
data, err, resp := api.PostRequest(
config.Env.MSHosts.EventsHost+"/persons/",
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}