Sync from /srv/compose/unified-media-manager
This commit is contained in:
24
internal/api/dashboard.go
Normal file
24
internal/api/dashboard.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/TopherMayor/unified-media-manager/internal/service"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func dashboard(svc *service.DashboardService) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
ctx, cancel := context.WithTimeout(c.Request().Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
stats, err := svc.Stats(ctx)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, stats)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user