From: 2weiEmu Date: Sat, 2 May 2026 16:33:00 +0000 (+0200) Subject: updated: get rooms method X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=66d8c7811bb735998d6fcc2100781cb3bc9b7b73;p=binbsis50-sm.git updated: get rooms method --- diff --git a/pkg/dbhandling/roomsapi.go b/pkg/dbhandling/roomsapi.go index b4f3a45..c57c2c9 100644 --- a/pkg/dbhandling/roomsapi.go +++ b/pkg/dbhandling/roomsapi.go @@ -1,6 +1,7 @@ package dbhandling import ( + "encoding/json" "net/http" ) @@ -28,34 +29,52 @@ func (dbw *DBWrapper) RoomsGet(w http.ResponseWriter, r *http.Request) { roomList = append(roomList, k) } } + + b, err := json.Marshal(roomList) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + w.Write(b) + w.WriteHeader(http.StatusOK) } /** TODO TEST - * + * Get the id's of the songs present in a room using the name of the room + * the sent JSON should just be a string with the name of the room **/ func (dbw *DBWrapper) RoomsGetByName(w http.ResponseWriter, r *http.Request) { } /** TODO TEST - * + * Create a new room with the given name + * Just a string value as the name + * May be rejected if a room with that name already exists **/ func (dbw *DBWrapper) RoomsCreate(w http.ResponseWriter, r *http.Request) { } /** TODO TEST - * + * Add songs to a room using the ID of the song and the NAME of the room + * The values should be given in the following way: + * { + * roomName: "NAME OF ROOM", + * songIds: [1, 2, 3, 4, 5], + * } **/ func (dbw *DBWrapper) RoomsAddByNameAndId(w http.ResponseWriter, r *http.Request) { } /** TODO TEST - * + * The same as adding, except that the IDs mentioned in the list will be removed from the room + * (if they are present) **/ func (dbw *DBWrapper) RoomsRemoveByNameAndId(w http.ResponseWriter, r *http.Request) { } /** TODO TEST - * + * Delete a room by giving the name as a string, this just means the room won't exist anymore **/ func (dbw *DBWrapper) RoomsDeleteByName(w http.ResponseWriter, r *http.Request) { }