Added method to show one namespace
This commit is contained in:
@ -7,7 +7,7 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// AddOrUpdateList Adds or updates a new list
|
||||
// GetListByID Adds or updates a new list
|
||||
func GetListByID(c echo.Context) error {
|
||||
// swagger:operation GET /lists/{listID} lists getList
|
||||
// ---
|
||||
|
52
routes/api/v1/namespace_show.go
Normal file
52
routes/api/v1/namespace_show.go
Normal file
@ -0,0 +1,52 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func ShowNamespace(c echo.Context) error {
|
||||
// swagger:operation GET /namespaces/{namespaceID} namespaces getNamespace
|
||||
// ---
|
||||
// summary: gets one namespace with all todo items
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: namespaceID
|
||||
// in: path
|
||||
// description: ID of the namespace to show
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/Namespace"
|
||||
// "400":
|
||||
// "$ref": "#/responses/Message"
|
||||
// "500":
|
||||
// "$ref": "#/responses/Message"
|
||||
|
||||
// Check if we have our ID
|
||||
id := c.Param("id")
|
||||
// Make int
|
||||
namespaceID, err := strconv.ParseInt(id, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
|
||||
}
|
||||
|
||||
// Get the namespace
|
||||
namespace, err := models.GetNamespaceByID(namespaceID)
|
||||
if err != nil {
|
||||
if models.IsErrNamespaceDoesNotExist(err) {
|
||||
return c.JSON(http.StatusBadRequest, models.Message{"The namespace does not exist."})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"An error occured."})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, namespace)
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo"
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -20,7 +20,6 @@ func GetAllNamespacesByCurrentUser(c echo.Context) error {
|
||||
// "500":
|
||||
// "$ref": "#/responses/Message"
|
||||
|
||||
|
||||
user, err := models.GetCurrentUser(c)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get the current user."})
|
||||
@ -32,4 +31,4 @@ func GetAllNamespacesByCurrentUser(c echo.Context) error {
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, namespaces)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user