2022-09-26 03:04:07 +00:00
|
|
|
package webserver
|
|
|
|
|
2022-09-26 06:54:32 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
2022-09-26 03:04:07 +00:00
|
|
|
|
|
|
|
func (s *Server) setupRoute() {
|
2022-09-26 06:54:32 +00:00
|
|
|
apiHandler := gin.New()
|
|
|
|
groupV1 := apiHandler.Group("/api/v1")
|
|
|
|
{
|
|
|
|
groupV1.
|
|
|
|
POST("/sdp", s.exchangeSDP).
|
|
|
|
GET("/instruction", s.getInstruction).
|
|
|
|
GET("/iceserver/url", s.getICEConfig).
|
|
|
|
GET("/name", s.getName)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.webServer.Use(func(ctx *gin.Context) {
|
|
|
|
path := ctx.Request.RequestURI
|
|
|
|
logrus.Debug(path)
|
|
|
|
if strings.HasPrefix(path, "/api") {
|
|
|
|
apiHandler.HandleContext(ctx)
|
|
|
|
} else {
|
|
|
|
staticFileHandler()(ctx)
|
|
|
|
}
|
|
|
|
})
|
2022-09-26 03:04:07 +00:00
|
|
|
}
|