x-movie/server/main.go

35 lines
564 B
Go

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)
}
})
api := eg.Group("/api")
api.POST("/login", loginHandler)
movie := eg.Group("movie")
movie.Use(jwtMiddleware())
movie.GET("/", MovieList)
eg.Run(":4444")
}