diff --git a/internal/api/member/authenticate.go b/internal/api/member/authenticate.go new file mode 100644 index 00000000..363b41ee --- /dev/null +++ b/internal/api/member/authenticate.go @@ -0,0 +1 @@ +package member diff --git a/internal/api/room/broadcast.go b/internal/api/room/broadcast.go new file mode 100644 index 00000000..01912655 --- /dev/null +++ b/internal/api/room/broadcast.go @@ -0,0 +1 @@ +package room diff --git a/internal/api/room/clipboard.go b/internal/api/room/clipboard.go new file mode 100644 index 00000000..01912655 --- /dev/null +++ b/internal/api/room/clipboard.go @@ -0,0 +1 @@ +package room diff --git a/internal/api/room/control.go b/internal/api/room/control.go new file mode 100644 index 00000000..01912655 --- /dev/null +++ b/internal/api/room/control.go @@ -0,0 +1 @@ +package room diff --git a/internal/api/room/keyboard.go b/internal/api/room/keyboard.go new file mode 100644 index 00000000..01912655 --- /dev/null +++ b/internal/api/room/keyboard.go @@ -0,0 +1 @@ +package room diff --git a/internal/api/room/resolution.go b/internal/api/room/resolution.go new file mode 100644 index 00000000..01912655 --- /dev/null +++ b/internal/api/room/resolution.go @@ -0,0 +1 @@ +package room diff --git a/internal/api/router.go b/internal/api/router.go new file mode 100644 index 00000000..b03f1a8d --- /dev/null +++ b/internal/api/router.go @@ -0,0 +1,40 @@ +package api + +import ( + "net/http" + + "github.com/go-chi/chi" + + // "demodesk/neko/internal/api/member" + // "demodesk/neko/internal/api/room" +) + +func Mount(router *chi.Mux) { + // all member routes + router.Mount("/member", MemberRoutes()) + + // all room routes + router.Mount("/room", RoomRoutes()) +} + +func MemberRoutes() *chi.Mux { + router := chi.NewRouter() + + router.Get("/test", func(w http.ResponseWriter, r *http.Request) { + //nolint + w.Write([]byte("hello world")) + }) + + return router +} + +func RoomRoutes() *chi.Mux { + router := chi.NewRouter() + + router.Get("/test", func(w http.ResponseWriter, r *http.Request) { + //nolint + w.Write([]byte("hello world")) + }) + + return router +} diff --git a/internal/http/http.go b/internal/http/http.go index 0a9b15bd..973405aa 100644 --- a/internal/http/http.go +++ b/internal/http/http.go @@ -11,6 +11,7 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "demodesk/neko/internal/api" "demodesk/neko/internal/http/endpoint" "demodesk/neko/internal/types" "demodesk/neko/internal/types/config" @@ -31,6 +32,9 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server { router.Use(middleware.RequestID) // Create a request ID for each request router.Use(Logger) // Log API request calls using custom logger function + // Mount REST API + api.Mount(router) + router.Get("/ws", func(w http.ResponseWriter, r *http.Request) { if webSocketHandler.Upgrade(w, r) != nil { //nolint