diff --git a/main.go b/main.go index db7a0e6..88b246c 100644 --- a/main.go +++ b/main.go @@ -53,6 +53,7 @@ func main() { mainGroup.GET("/users/me", users.GetCurrentUser) mainGroup.GET("/users", users.GetUsers) mainGroup.GET("/users/:id", users.GetUsers) + mainGroup.POST("/users/:id/avatar", users.UploadAvatar) mainGroup.DELETE("/users/:id", users.DeleteUser) mainGroup.PATCH("/users/:id", users.UpdateUser) mainGroup.GET("/users/organizations", users.GetOrganizations) diff --git a/pkg/api/apiCall.go b/pkg/api/apiCall.go index 3206029..ac715cb 100644 --- a/pkg/api/apiCall.go +++ b/pkg/api/apiCall.go @@ -11,7 +11,6 @@ func PostRequest(url string, body io.Reader, header http.Header) ([]byte, error, client := http.Client{} req, err := http.NewRequest("POST", url, body) req.Header = header - req.Header.Set("Content-Type", "application/json") resp, err := client.Do(req) diff --git a/services/users/users.go b/services/users/users.go index 617c8cb..cd3e4be 100644 --- a/services/users/users.go +++ b/services/users/users.go @@ -134,3 +134,17 @@ func GetPositions(c echo.Context) error { return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data) } + +func UploadAvatar(c echo.Context) error { + id := c.Param("id") + data, err, resp := api.PostRequest( + config.Env.MSHosts.UsersHost+"/"+id+"/avatar", + 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) +}