mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-02 17:59:14 +02:00
fix:#150 fixed return
This commit is contained in:
@@ -23,18 +23,22 @@ func GetRooms(app *pocketbase.PocketBase) ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
roomArray := clearAndSeparateRooms([]struct {
|
||||
roomArray, err := clearAndSeparateRooms([]struct {
|
||||
Rooms string
|
||||
Course string
|
||||
}(events))
|
||||
|
||||
return roomArray
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return roomArray, nil
|
||||
}
|
||||
|
||||
func clearAndSeparateRooms(events []struct {
|
||||
Rooms string
|
||||
Course string
|
||||
}) []string {
|
||||
}) ([]string, error) {
|
||||
var roomArray []string
|
||||
for _, event := range events {
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package room
|
||||
import (
|
||||
"htwkalender/model"
|
||||
"htwkalender/service/db"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
@@ -13,7 +14,8 @@ func GetRooms(c echo.Context, app *pocketbase.PocketBase) error {
|
||||
rooms, err := db.GetRooms(app)
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusNotFound, err)
|
||||
slog.Error("Error getting rooms: ", err)
|
||||
return c.JSON(http.StatusNotFound, "No rooms found")
|
||||
} else {
|
||||
return c.JSON(http.StatusOK, rooms)
|
||||
}
|
||||
|
Reference in New Issue
Block a user