esbuild embed
This commit is contained in:
17
main.go
17
main.go
@@ -3,11 +3,28 @@ package main
|
|||||||
import (
|
import (
|
||||||
"ais/pkg/api"
|
"ais/pkg/api"
|
||||||
|
|
||||||
|
_ "embed"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed web/public/index.html
|
||||||
|
var indexhtml string
|
||||||
|
|
||||||
|
//go:embed web/public/ais.js
|
||||||
|
var aisjs string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
router := api.NewAPI()
|
router := api.NewAPI()
|
||||||
|
|
||||||
|
router.GET("/", func(c *gin.Context) {
|
||||||
|
c.Header("Content-Type", "text/html")
|
||||||
|
c.String(200, indexhtml)
|
||||||
|
})
|
||||||
|
router.GET("/ais.js", func(c *gin.Context) {
|
||||||
|
c.Header("Content-Type", "text/javascript")
|
||||||
|
c.String(200, aisjs)
|
||||||
|
})
|
||||||
|
|
||||||
router.Run(":8888")
|
router.Run(":8888")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,11 +60,6 @@ func NewAPI() *gin.Engine {
|
|||||||
store := cookie.NewStore([]byte("Miku saves the world!"))
|
store := cookie.NewStore([]byte("Miku saves the world!"))
|
||||||
router.Use(sessions.Sessions("ais", store))
|
router.Use(sessions.Sessions("ais", store))
|
||||||
|
|
||||||
// entry point html
|
|
||||||
router.GET("/", func(c *gin.Context) {
|
|
||||||
c.File("./web/public/index.html")
|
|
||||||
})
|
|
||||||
|
|
||||||
group := router.Group("/api")
|
group := router.Group("/api")
|
||||||
|
|
||||||
// json error middleware
|
// json error middleware
|
||||||
|
|||||||
Reference in New Issue
Block a user