mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
create api skeleton.
This commit is contained in:
parent
fc3ee13f65
commit
5acd428dee
1
internal/api/member/authenticate.go
Normal file
1
internal/api/member/authenticate.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package member
|
1
internal/api/room/broadcast.go
Normal file
1
internal/api/room/broadcast.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package room
|
1
internal/api/room/clipboard.go
Normal file
1
internal/api/room/clipboard.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package room
|
1
internal/api/room/control.go
Normal file
1
internal/api/room/control.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package room
|
1
internal/api/room/keyboard.go
Normal file
1
internal/api/room/keyboard.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package room
|
1
internal/api/room/resolution.go
Normal file
1
internal/api/room/resolution.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package room
|
40
internal/api/router.go
Normal file
40
internal/api/router.go
Normal file
@ -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
|
||||||
|
}
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/api"
|
||||||
"demodesk/neko/internal/http/endpoint"
|
"demodesk/neko/internal/http/endpoint"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/config"
|
"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(middleware.RequestID) // Create a request ID for each request
|
||||||
router.Use(Logger) // Log API request calls using custom logger function
|
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) {
|
router.Get("/ws", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if webSocketHandler.Upgrade(w, r) != nil {
|
if webSocketHandler.Upgrade(w, r) != nil {
|
||||||
//nolint
|
//nolint
|
||||||
|
Loading…
Reference in New Issue
Block a user