Ejemplo n.º 1
0
func (a *API) getResources(c *gin.Context) {
	s := services.ResourceService{}
	resType := c.Param("type")
	res, err := s.GetResources(a.DB, resType)
	if err != nil {
		c.JSON(500, err.Error())
		return
	}
	c.JSON(200, gin.H{"resources": res})
}
Ejemplo n.º 2
0
func (a *API) createResource(c *gin.Context) {
	res, err := resources.UnmarshalJSON(c.Request)
	if err != nil {
		c.JSON(500, err.Error())
		return
	}
	s := services.ResourceService{}
	err = s.InsertResource(a.DB, res)
	if err != nil {
		c.JSON(500, err.Error())
		return
	}
	c.JSON(200, "")
}