]> git.example.dev Git - binbsis50-sm.git/commitdiff
updated: new method plan to allow all modifications and have better db
author2weiEmu <saalbach.robert@outlook.de>
Mon, 13 Apr 2026 06:50:32 +0000 (08:50 +0200)
committer2weiEmu <saalbach.robert@outlook.de>
Mon, 13 Apr 2026 06:50:32 +0000 (08:50 +0200)
overview

main.go
pkg/dbhandling/filesapi.go [new file with mode: 0644]
pkg/dbhandling/roomsapi.go [new file with mode: 0644]
pkg/dbhandling/songsapi.go [new file with mode: 0644]

diff --git a/main.go b/main.go
index ec7cd409738eac76afc2c915e71e25eefe4f01e1..8fedd66a43fd736df374dbc65470676fcba0f654 100644 (file)
--- 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 (file)
index 0000000..3f1278b
--- /dev/null
@@ -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 (file)
index 0000000..0f38929
--- /dev/null
@@ -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 (file)
index 0000000..98e7091
--- /dev/null
@@ -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
+       }
+}