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.StaticFile("/manifest.json", "../build/manifest.json") eg.StaticFile("/favicon.ico", "../build/favicon.ico") eg.StaticFile("/logo512.png", "../build/logo512.png") eg.StaticFile("/logo192.png", "../build/logo192.png") 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) } }) api := eg.Group("/api") api.POST("/login", loginHandler) movie := eg.Group("movie") movie.Use(jwtMiddleware()) movie.GET("/", MovieList) eg.Run("0.0.0.0:4444") }