add Makefile, fixed websocket url for https

This commit is contained in:
RockYang
2023-03-23 18:10:23 +08:00
parent a061881d4a
commit 2067aa3f83
9 changed files with 72 additions and 9 deletions

View File

@@ -68,7 +68,7 @@ func NewServer(configPath string) (*Server, error) {
}
func (s *Server) Run(webRoot embed.FS, path string) {
gin.SetMode(gin.DebugMode)
gin.SetMode(gin.ReleaseMode)
engine := gin.Default()
engine.Use(sessionMiddleware(s.Config))
engine.Use(corsMiddleware())
@@ -80,6 +80,12 @@ func (s *Server) Run(webRoot embed.FS, path string) {
engine.Any("/api/chat", s.ChatHandle)
engine.POST("/api/config/set", s.ConfigSetHandle)
engine.NoRoute(func(c *gin.Context) {
if c.Request.URL.Path == "/favicon.ico" {
c.Redirect(http.StatusMovedPermanently, "/chat/"+c.Request.URL.Path)
}
})
// process front-end web static files
engine.StaticFS("/chat", http.FS(StaticFile{
embedFS: webRoot,