x-movie/server/main.go

39 lines
795 B
Go
Raw Permalink 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")
2023-07-09 16:50:11 +00:00
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")
2023-07-04 15:47:01 +00:00
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)
2024-06-12 04:51:12 +00:00
eg.Run("0.0.0.0:4444")
2023-07-04 15:47:01 +00:00
}