routes restructoring

This commit is contained in:
Mitsu
2025-07-12 15:03:33 +02:00
parent e411536477
commit 77120bce29
4 changed files with 116 additions and 66 deletions
+21
View File
@@ -0,0 +1,21 @@
package routes
import (
"net/http"
"github.com/siestaw/laterna/server/cmd/internal/db"
"github.com/siestaw/laterna/server/cmd/utils"
)
func RegisterAdminRoutes(mux *http.ServeMux) {
mux.HandleFunc("POST /api/v1/admin/controllers", createController)
}
func createController(w http.ResponseWriter, r *http.Request) {
auth := r.Header.Get("Authorization")
if !db.IsAdmin(auth) {
utils.HTTPErrorHandling(w, r, http.StatusUnauthorized, "Invalid token")
return
}
}