fasten-onprem/backend/pkg/web/handler/summary.go

22 lines
593 B
Go
Raw Normal View History

2022-09-17 11:14:59 -06:00
package handler
import (
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"net/http"
)
func GetSummary(c *gin.Context) {
logger := c.MustGet("LOGGER").(*logrus.Entry)
databaseRepo := c.MustGet("REPOSITORY").(database.DatabaseRepository)
summary, err := databaseRepo.GetSummary(c)
if err != nil {
logger.Errorln("An error occurred while retrieving summary", err)
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "data": summary})
}