feature:#150 added slog and changed signatures

This commit is contained in:
Elmar Kresse
2024-01-21 17:53:49 +01:00
parent a9e76ee3db
commit 031fa717d7
9 changed files with 77 additions and 60 deletions

View File

@@ -9,6 +9,7 @@ import (
"htwkalender/service/ical"
"htwkalender/service/room"
"io"
"log/slog"
"net/http"
"github.com/labstack/echo/v5"
@@ -24,7 +25,13 @@ func AddRoutes(app *pocketbase.PocketBase) {
Method: http.MethodGet,
Path: "/api/fetch/events",
Handler: func(c echo.Context) error {
return v2.ParseEventsFromRemote(c, app)
savedEvents, err := v2.ParseEventsFromRemote(app)
if err != nil {
slog.Error("Failed to parse events from remote: %v", err)
return c.JSON(http.StatusInternalServerError, "Failed to parse events from remote")
} else {
return c.JSON(http.StatusOK, savedEvents)
}
},
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(app),