mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: build with no embedded front-end files
This commit is contained in:
parent
b090564a34
commit
a560d98acf
10 changed files with 91 additions and 35 deletions
|
@ -1,6 +1,8 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/api/analytic"
|
||||
"github.com/0xJacky/Nginx-UI/api/certificate"
|
||||
"github.com/0xJacky/Nginx-UI/api/cluster"
|
||||
|
@ -19,19 +21,14 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/api/upstream"
|
||||
"github.com/0xJacky/Nginx-UI/api/user"
|
||||
"github.com/0xJacky/Nginx-UI/internal/middleware"
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func InitRouter() {
|
||||
r := cosy.GetEngine()
|
||||
r.Use(
|
||||
middleware.CacheJs(),
|
||||
middleware.IPWhiteList(),
|
||||
static.Serve("/", middleware.MustFs("")),
|
||||
)
|
||||
|
||||
initEmbedRoute(r)
|
||||
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
|
|
17
router/routers_embed.go
Normal file
17
router/routers_embed.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
//go:build !unembed
|
||||
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/middleware"
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func initEmbedRoute(r *gin.Engine) {
|
||||
r.Use(
|
||||
middleware.CacheJs(),
|
||||
middleware.IPWhiteList(),
|
||||
static.Serve("/", middleware.MustFs("")),
|
||||
)
|
||||
}
|
8
router/routers_unembed.go
Normal file
8
router/routers_unembed.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
//go:build unembed
|
||||
|
||||
package router
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func initEmbedRoute(r *gin.Engine) {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue