initial commit
This commit is contained in:
21
http/route/api.go
Normal file
21
http/route/api.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"rkkvm/http/hw/stream"
|
||||
"rkkvm/http/middleware"
|
||||
"rkkvm/http/ws"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Api(e *gin.Engine) {
|
||||
api := e.Group("/api").Use(middleware.CheckToken())
|
||||
|
||||
api.GET("/stream/mjpeg", stream.MjpegHandler)
|
||||
api.GET("/stream/audio", stream.AudioHandler)
|
||||
api.GET("/ws", ws.ConnHandler)
|
||||
|
||||
api.POST("/stream/webrtc", stream.WebRTCHandshake)
|
||||
|
||||
api.GET("/stream/webrtc", stream.WebRTCSettings)
|
||||
}
|
||||
20
http/route/static.go
Normal file
20
http/route/static.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func Static(e *gin.Engine) {
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
panic("invalid executable path")
|
||||
}
|
||||
|
||||
execDir := filepath.Dir(execPath)
|
||||
webPath := fmt.Sprintf("%s/static", execDir)
|
||||
e.Use(static.Serve("/", static.LocalFile(webPath, true)))
|
||||
}
|
||||
Reference in New Issue
Block a user