x-movie/server/main.go

35 lines
564 B
Go
Raw Normal View History

2023-07-04 15:47:01 +00:00
package main
import (
"net/http"
"path/filepath"
"github.com/gin-gonic/gin"
)
func main() {
initMovie()
eg := gin.Default()
eg.Use(Cors())
eg.Static("/res", "movie/")
eg.Static("/static", "../build/static")
eg.NoRoute(func(c *gin.Context) {
path := c.Request.URL.Path
if filepath.Ext(path) == "" {
c.File("../build/index.html")
} else {
c.Status(http.StatusNotFound)
}
})
2023-07-08 19:00:29 +00:00
api := eg.Group("/api")
api.POST("/login", loginHandler)
2023-07-04 15:47:01 +00:00
movie := eg.Group("movie")
2023-07-08 19:00:29 +00:00
movie.Use(jwtMiddleware())
2023-07-04 15:47:01 +00:00
movie.GET("/", MovieList)
eg.Run(":4444")
}