mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-07 20:29:13 +02:00
feat:#36 added protobuf communication for modules
This commit is contained in:
@@ -12,13 +12,13 @@ import (
|
||||
|
||||
// AddFeedRoutes add routes to the app instance for the data-manager ical service
|
||||
// with golang fiber
|
||||
func AddFeedRoutes(app *fiber.App) {
|
||||
func AddFeedRoutes(app model.AppType) {
|
||||
|
||||
// Define a route for the GET method on the root path '/'
|
||||
app.Get("/api/feed", func(c fiber.Ctx) error {
|
||||
app.Fiber.Get("/api/feed", func(c fiber.Ctx) error {
|
||||
|
||||
token := c.Query("token")
|
||||
results, err := ical.Feed(token)
|
||||
results, err := ical.Feed(app, token)
|
||||
|
||||
if err != nil {
|
||||
slog.Error("Failed to get feed", "error", err)
|
||||
@@ -33,7 +33,7 @@ func AddFeedRoutes(app *fiber.App) {
|
||||
})
|
||||
|
||||
// Define a route for the POST method on the root path '/api/feed'
|
||||
app.Post("/api/feed", func(c fiber.Ctx) error {
|
||||
app.Fiber.Post("/api/feed", func(c fiber.Ctx) error {
|
||||
var modules []model.FeedCollection
|
||||
//obtain the body of the request
|
||||
err := json.Unmarshal(c.Body(), &modules)
|
||||
@@ -43,7 +43,7 @@ func AddFeedRoutes(app *fiber.App) {
|
||||
}
|
||||
|
||||
//create a new feed
|
||||
token, err := ical.CreateFeed(modules)
|
||||
token, err := ical.CreateFeed(app, modules)
|
||||
if err != nil {
|
||||
println(err)
|
||||
log.Error("Failed to create feed", "error", err)
|
||||
@@ -54,10 +54,10 @@ func AddFeedRoutes(app *fiber.App) {
|
||||
})
|
||||
|
||||
// Define a route for the GET method on the root path '/'
|
||||
app.Get("/api/collections/feeds/records/:token", func(c fiber.Ctx) error {
|
||||
app.Fiber.Get("/api/collections/feeds/records/:token", func(c fiber.Ctx) error {
|
||||
|
||||
token := c.Params("token")
|
||||
results, err := ical.FeedRecord(token)
|
||||
results, err := ical.FeedRecord(app, token)
|
||||
|
||||
if err != nil {
|
||||
slog.Error("Failed to get feed", "error", err)
|
||||
@@ -68,10 +68,10 @@ func AddFeedRoutes(app *fiber.App) {
|
||||
return c.JSON(results)
|
||||
})
|
||||
|
||||
app.Delete("/api/feed", func(c fiber.Ctx) error {
|
||||
app.Fiber.Delete("/api/feed", func(c fiber.Ctx) error {
|
||||
|
||||
token := c.Query("token")
|
||||
err := ical.DeleteFeedRecord(token)
|
||||
err := ical.DeleteFeedRecord(app, token)
|
||||
if err != nil {
|
||||
slog.Error("Feed could not be deleted", "error", err)
|
||||
return c.JSON(http.StatusNotFound, "Feed could not be deleted")
|
||||
@@ -80,28 +80,28 @@ func AddFeedRoutes(app *fiber.App) {
|
||||
}
|
||||
})
|
||||
|
||||
app.Put("/api/feed", func(c fiber.Ctx) error {
|
||||
app.Fiber.Put("/api/feed", func(c fiber.Ctx) error {
|
||||
token := c.Query("token")
|
||||
return c.JSON(http.StatusOK, "token: "+token)
|
||||
})
|
||||
|
||||
app.Head("/api/feed", func(c fiber.Ctx) error {
|
||||
app.Fiber.Head("/api/feed", func(c fiber.Ctx) error {
|
||||
return c.JSON(http.StatusOK, "")
|
||||
})
|
||||
|
||||
app.Add([]string{"PROPFIND"}, "/api/feed", func(c fiber.Ctx) error {
|
||||
app.Fiber.Add([]string{"PROPFIND"}, "/api/feed", func(c fiber.Ctx) error {
|
||||
return c.JSON(http.StatusOK, "")
|
||||
})
|
||||
|
||||
// Route for Thunderbird to get calendar server information
|
||||
// Response is a 200 OK without additional content
|
||||
app.Add([]string{"PROPFIND"}, "/.well-known/caldav", func(c fiber.Ctx) error {
|
||||
app.Fiber.Add([]string{"PROPFIND"}, "/.well-known/caldav", func(c fiber.Ctx) error {
|
||||
return c.JSON(http.StatusOK, "")
|
||||
})
|
||||
|
||||
// Route for Thunderbird to get calendar server information
|
||||
// Response is a 200 OK without additional content
|
||||
app.Add([]string{"PROPFIND"}, "/", func(c fiber.Ctx) error {
|
||||
app.Fiber.Add([]string{"PROPFIND"}, "/", func(c fiber.Ctx) error {
|
||||
return c.JSON(http.StatusOK, "")
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user