ace/servers/webserver/routers.go
2022-09-26 06:54:32 +00:00

31 lines
576 B
Go

package webserver
import (
"strings"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
func (s *Server) setupRoute() {
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)
}
})
}