Library/routes/api/v1/logs.go

26 lines
465 B
Go
Raw Normal View History

2018-03-06 14:33:18 +00:00
package v1
import (
"git.kolaente.de/konrad/Library/models"
2018-04-13 13:05:23 +00:00
"github.com/labstack/echo"
2018-03-06 14:33:18 +00:00
"net/http"
)
2018-04-13 12:41:31 +00:00
// ShowLogs handels viewing logs
2018-03-06 14:33:18 +00:00
func ShowLogs(c echo.Context) error {
// Check if the user is admin
if !models.IsAdmin(c) {
return echo.ErrUnauthorized
}
// Get the logs
logs, err := models.GetAllLogs()
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting logs."})
}
return c.JSON(http.StatusOK, logs)
2018-04-13 13:05:23 +00:00
}