mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-10 05:37:44 +02:00
feat:#16 added room ics api route
This commit is contained in:
@@ -120,6 +120,27 @@ func AddFeedRoutes(app model.AppType) {
|
||||
return c.JSON(http.StatusOK, "token: "+token)
|
||||
})
|
||||
|
||||
app.Fiber.Get("/api/feed/room", func(c fiber.Ctx) error {
|
||||
room := c.Query("id")
|
||||
ifNoneMatch := c.Get("If-None-Match")
|
||||
|
||||
results, etag, err := ical.FeedRoom(app, room)
|
||||
if err != nil {
|
||||
slog.Error("Failed to get feed", "error", err, "room", room)
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
}
|
||||
|
||||
if ifNoneMatch == etag && ifNoneMatch != "" {
|
||||
return c.SendStatus(fiber.StatusNotModified)
|
||||
}
|
||||
|
||||
c.Response().Header.Set("Content-type", "text/calendar")
|
||||
c.Response().Header.Set("charset", "utf-8")
|
||||
c.Response().Header.Set("Content-Disposition", "inline")
|
||||
c.Response().Header.Set("filename", "calendar.ics")
|
||||
return c.SendString(results)
|
||||
})
|
||||
|
||||
app.Fiber.Head("/api/feed", func(c fiber.Ctx) error {
|
||||
return c.JSON(http.StatusOK, "")
|
||||
})
|
||||
|
Reference in New Issue
Block a user