From: 2weiEmu Date: Mon, 13 Apr 2026 06:50:32 +0000 (+0200) Subject: updated: new method plan to allow all modifications and have better db X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=24daa748c045d1db0726c70f1290fefcdf54f8a5;p=binbsis50-sm.git updated: new method plan to allow all modifications and have better db overview --- diff --git a/main.go b/main.go index ec7cd40..8fedd66 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,27 @@ func main() { mux.HandleFunc("/api/getSongFiles", DBwrapper.GetSongFiles) mux.Handle("/", http.FileServer(http.Dir("./public/"))) + // api/songs/ - api related to raw songs + mux.HandleFunc("/api/songs/get", DBwrapper.SongsGet) + mux.HandleFunc("/api/songs/create", DBwrapper.SongsCreate) + mux.HandleFunc("/api/songs/update/{id}", DBwrapper.SongsUpdateById) + mux.HandleFunc("/api/songs/delete/{id}", DBwrapper.SongsDeleteById) + + // api/rooms - api related to managaing rooms + mux.HandleFunc("/api/rooms/get", DBwrapper.RoomsGet) + mux.HandleFunc("/api/rooms/create/", DBwrapper.RoomsCreate) + mux.HandleFunc("/api/rooms/add/{name}/{id}", DBwrapper.RoomsAddByNameAndId) + mux.HandleFunc("/api/rooms/remove/{name}/{id}", DBwrapper.RoomsRemoveByNameAndId) + mux.HandleFunc("/api/rooms/delete/{name}", DBwrapper.RoomsDeleteByName) + + // api/files - api related to song files + mux.HandleFunc("/api/files/get", DBwrapper.FilesGet) + mux.HandleFunc("/api/files/createWithURL", DBwrapper.FilesCreateWithURL) + mux.HandleFunc("/api/files/createWithUpload", DBwrapper.FilesCreateWithUpload) + mux.HandleFunc("/api/files/delete/{id}", DBwrapper.FilesDeleteById) + mux.HandleFunc("/api/files/rename/{id}", DBwrapper.FilesRenameById) + mux.HandleFunc("/api/files/replace/{id}", DBwrapper.FilesReplaceById) + listenPort := ":" + strconv.Itoa(*paramPort) fmt.Println("Starting server...") diff --git a/pkg/dbhandling/filesapi.go b/pkg/dbhandling/filesapi.go new file mode 100644 index 0000000..3f1278b --- /dev/null +++ b/pkg/dbhandling/filesapi.go @@ -0,0 +1,63 @@ +package dbhandling + +import "net/http" + +/** TODO + * + **/ +func (dbw *DBWrapper) FilesGet(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) FilesCreateWithURL(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) FilesCreateWithUpload(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) FilesDeleteById(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) FilesRenameById(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) FilesReplaceById(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} diff --git a/pkg/dbhandling/roomsapi.go b/pkg/dbhandling/roomsapi.go new file mode 100644 index 0000000..0f38929 --- /dev/null +++ b/pkg/dbhandling/roomsapi.go @@ -0,0 +1,53 @@ +package dbhandling + +import "net/http" + +/** TODO + * + **/ +func (dbw *DBWrapper) RoomsGet(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) RoomsCreate(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) RoomsAddByNameAndId(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) RoomsRemoveByNameAndId(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * + **/ +func (dbw *DBWrapper) RoomsDeleteByName(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} diff --git a/pkg/dbhandling/songsapi.go b/pkg/dbhandling/songsapi.go new file mode 100644 index 0000000..98e7091 --- /dev/null +++ b/pkg/dbhandling/songsapi.go @@ -0,0 +1,55 @@ +package dbhandling + +import "net/http" + +/** TODO + * Get all songs, and all their assosciated information from the db + **/ +func (dbw *DBWrapper) SongsGet(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + + // Here we should return an entire list of songs +} + +/** TODO + * Create a new song in the database (only in the main list don't add to anything) + **/ +func (dbw *DBWrapper) SongsCreate(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * Create a new song in the database (only in the main list don't add to anything) + **/ +func (dbw *DBWrapper) SongsCreate(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * Create a new song in the database (only in the main list don't add to anything) + **/ +func (dbw *DBWrapper) SongsUpdateById(w http.ResponseWriter, r *http.Request) { + if r.Method != "PUT" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +} + +/** TODO + * Create a new song in the database (only in the main list don't add to anything) + **/ +func (dbw *DBWrapper) SongsDeleteById(w http.ResponseWriter, r *http.Request) { + if r.Method != "DELETE" { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } +}