-
Notifications
You must be signed in to change notification settings - Fork 0
/
baask8sgroup_inspect.go
executable file
·27 lines (22 loc) · 1.05 KB
/
baask8sgroup_inspect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package baask8sgroups
import (
"net/http"
httperror "github.com/baasapi/libhttp/error"
"github.com/baasapi/libhttp/request"
"github.com/baasapi/libhttp/response"
"github.com/baasapi/baasapi/api"
)
// GET request on /api/baask8s_groups/:id
func (handler *Handler) baask8sGroupInspect(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
baask8sGroupID, err := request.RetrieveNumericRouteVariableValue(r, "id")
if err != nil {
return &httperror.HandlerError{http.StatusBadRequest, "Invalid baask8s group identifier route variable", err}
}
baask8sGroup, err := handler.Baask8sGroupService.Baask8sGroup(baasapi.Baask8sGroupID(baask8sGroupID))
if err == baasapi.ErrObjectNotFound {
return &httperror.HandlerError{http.StatusNotFound, "Unable to find an baask8s group with the specified identifier inside the database", err}
} else if err != nil {
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find an baask8s group with the specified identifier inside the database", err}
}
return response.JSON(w, baask8sGroup)
}