fixed schedule and update process

This commit is contained in:
masterelmar
2023-10-08 18:22:34 +02:00
parent 3225a9040e
commit 9a1342b954
5 changed files with 82 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ import (
"htwkalender/service/fetch"
"htwkalender/service/ical"
"htwkalender/service/room"
"io"
"net/http"
"os"
)
@@ -71,6 +72,7 @@ func AddRoutes(app *pocketbase.PocketBase) {
return nil
})
// API Endpoint to get all events for a specific room on a specific day
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
_, err := e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
@@ -90,12 +92,19 @@ func AddRoutes(app *pocketbase.PocketBase) {
return nil
})
// API Endpoint to create a new iCal feed
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
_, err := e.Router.AddRoute(echo.Route{
Method: http.MethodPost,
Path: "/api/createFeed",
Handler: func(c echo.Context) error {
return ical.CreateIndividualFeed(c, app)
requestBody, _ := io.ReadAll(c.Request().Body)
result, err := ical.CreateIndividualFeed(requestBody, app)
if err != nil {
return c.JSON(http.StatusInternalServerError, err)
}
return c.JSON(http.StatusOK, result)
},
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(app),