add new endpoints
This commit is contained in:
@@ -7,6 +7,17 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetPDDocs(c echo.Context) error {
|
||||
data, err, resp := api.GetRequest(
|
||||
config.Env.MSHosts.PersonsHost+"/docs",
|
||||
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 GetPDList(c echo.Context) error {
|
||||
data, err, resp := api.GetRequest(
|
||||
config.Env.MSHosts.PersonsHost+"/persons/",
|
||||
@@ -45,3 +56,120 @@ func CreatePD(c echo.Context) error {
|
||||
|
||||
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||
}
|
||||
func CreateDocuments(c echo.Context) error {
|
||||
data, err, resp := api.PostRequest(
|
||||
config.Env.MSHosts.EventsHost+"/documents/",
|
||||
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)
|
||||
}
|
||||
func CreateContacts(c echo.Context) error {
|
||||
data, err, resp := api.PostRequest(
|
||||
config.Env.MSHosts.EventsHost+"/contacts/",
|
||||
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)
|
||||
}
|
||||
func CreateAddress(c echo.Context) error {
|
||||
data, err, resp := api.PostRequest(
|
||||
config.Env.MSHosts.EventsHost+"/address/",
|
||||
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)
|
||||
}
|
||||
func UpdateDocuments(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
data, err, resp := api.PatchRequest(
|
||||
config.Env.MSHosts.EventsHost+"/documents/"+id,
|
||||
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)
|
||||
}
|
||||
func UpdateContacts(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
data, err, resp := api.PatchRequest(
|
||||
config.Env.MSHosts.EventsHost+"/contacts/"+id,
|
||||
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)
|
||||
}
|
||||
func UpdateAddress(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
data, err, resp := api.PatchRequest(
|
||||
config.Env.MSHosts.EventsHost+"/address/"+id,
|
||||
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)
|
||||
}
|
||||
func DeleteDocuments(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
data, err, resp := api.DeleteRequest(
|
||||
config.Env.MSHosts.EventsHost+"/documents/"+id,
|
||||
c.Request().Header)
|
||||
|
||||
if err != nil {
|
||||
return c.NoContent(http.StatusBadGateway)
|
||||
}
|
||||
|
||||
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||
}
|
||||
func DeleteContacts(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
data, err, resp := api.DeleteRequest(
|
||||
config.Env.MSHosts.EventsHost+"/contacts/"+id,
|
||||
c.Request().Header)
|
||||
|
||||
if err != nil {
|
||||
return c.NoContent(http.StatusBadGateway)
|
||||
}
|
||||
|
||||
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||
}
|
||||
func DeleteAddress(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
|
||||
data, err, resp := api.DeleteRequest(
|
||||
config.Env.MSHosts.EventsHost+"/address/"+id,
|
||||
c.Request().Header)
|
||||
|
||||
if err != nil {
|
||||
return c.NoContent(http.StatusBadGateway)
|
||||
}
|
||||
|
||||
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
|
||||
}
|
||||
|
||||
@@ -107,13 +107,7 @@ func DeleteUser(c echo.Context) error {
|
||||
func UpdateUser(c echo.Context) (err error) {
|
||||
id := c.Param("id")
|
||||
|
||||
// Bind
|
||||
u := new(model.User)
|
||||
if err = c.Bind(u); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := api.PatchRequest(config.Env.MSHosts.UsersHost+"/"+id, u, c.Request().Header)
|
||||
data, err, _ := api.PatchRequest(config.Env.MSHosts.UsersHost+"/"+id, c.Request().Body, c.Request().Header)
|
||||
|
||||
if err != nil {
|
||||
return c.NoContent(http.StatusBadGateway)
|
||||
|
||||
Reference in New Issue
Block a user