From 0027b1f00151f9354d188768f938228fe87642fc Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 23 Jan 2018 15:20:02 +0100 Subject: [PATCH] Added method to get information about a user --- routes/api/v1/user_add_update.go | 5 +++++ routes/routes.go | 1 + 2 files changed, 6 insertions(+) diff --git a/routes/api/v1/user_add_update.go b/routes/api/v1/user_add_update.go index f63993d..8a4aae6 100644 --- a/routes/api/v1/user_add_update.go +++ b/routes/api/v1/user_add_update.go @@ -67,6 +67,11 @@ func UserAddOrUpdate(c echo.Context) error { return c.JSON(http.StatusBadRequest, models.Message{"Please specify a username."}) } + // Check for user does not exist + if models.IsErrUserDoesNotExist(err) { + return c.JSON(http.StatusBadRequest, models.Message{"The user does not exist."}) + } + return c.JSON(http.StatusInternalServerError, models.Message{"Error"}) } diff --git a/routes/routes.go b/routes/routes.go index f772c42..b8c466f 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -111,6 +111,7 @@ func RegisterRoutes(e *echo.Echo) { a.GET("/users", apiv1.UsersList) a.PUT("/users", apiv1.UserAddOrUpdate) a.POST("/users/:id", apiv1.UserAddOrUpdate) + a.GET("/users/:id", apiv1.UserShow) // Manage Users