mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-08 20:57:45 +02:00
feat:#44 updated delete process and api response
This commit is contained in:
@@ -1,7 +1,24 @@
|
||||
//Calendar implementation for the HTWK Leipzig timetable. Evaluation and display of the individual dates in iCal format.
|
||||
//Copyright (C) 2024 HTWKalender support@htwkalender.de
|
||||
|
||||
//This program is free software: you can redistribute it and/or modify
|
||||
//it under the terms of the GNU Affero General Public License as published by
|
||||
//the Free Software Foundation, either version 3 of the License, or
|
||||
//(at your option) any later version.
|
||||
|
||||
//This program is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU Affero General Public License for more details.
|
||||
|
||||
//You should have received a copy of the GNU Affero General Public License
|
||||
//along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"htwkalender/ical/model"
|
||||
"htwkalender/ical/service/ical"
|
||||
@@ -19,9 +36,13 @@ func AddFeedRoutes(app model.AppType) {
|
||||
token := c.Query("token")
|
||||
results, err := ical.Feed(app, token)
|
||||
|
||||
if errors.Is(err, ical.FeedDeletedError) {
|
||||
return c.SendStatus(fiber.StatusGone)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
slog.Error("Failed to get feed", "error", err, "token", token)
|
||||
return c.SendStatus(fiber.StatusGone)
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
}
|
||||
c.Response().Header.Set("Content-type", "text/calendar")
|
||||
c.Response().Header.Set("charset", "utf-8")
|
||||
@@ -53,7 +74,7 @@ func AddFeedRoutes(app model.AppType) {
|
||||
})
|
||||
|
||||
// Define a route for the GET method on the root path '/'
|
||||
app.Fiber.Get("/api/collections/feeds/records/:token", func(c fiber.Ctx) error {
|
||||
app.Fiber.Get("/api/feeds/records/:token", func(c fiber.Ctx) error {
|
||||
|
||||
token := c.Params("token")
|
||||
results, err := ical.FeedRecord(app, token)
|
||||
|
Reference in New Issue
Block a user