to:sync
This commit is contained in:
parent
c2f307b3f7
commit
cd1fc2a48b
3
main.go
3
main.go
@ -5,6 +5,7 @@ import (
|
|||||||
"ai-gateway/common/constant"
|
"ai-gateway/common/constant"
|
||||||
"ai-gateway/common/filter"
|
"ai-gateway/common/filter"
|
||||||
"ai-gateway/common/utils"
|
"ai-gateway/common/utils"
|
||||||
|
"ai-gateway/static"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@ -56,7 +57,7 @@ func main() {
|
|||||||
//user
|
//user
|
||||||
apps.InitUserGroup(e.Group("/v1/user/"))
|
apps.InitUserGroup(e.Group("/v1/user/"))
|
||||||
|
|
||||||
apps.InitStaticGroup(e.Group("/v1/static/"))
|
static.InitStaticGroup(e.Group("/v1/static/"))
|
||||||
|
|
||||||
//ai
|
//ai
|
||||||
apps.InitAiGroup(e.Group("/v1/ai/", func(next echo.HandlerFunc) echo.HandlerFunc {
|
apps.InitAiGroup(e.Group("/v1/ai/", func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
54
static/init.go
Normal file
54
static/init.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package static
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
)
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
//go:embed *.html
|
||||||
|
var pageList embed.FS
|
||||||
|
|
||||||
|
//go:embed img/*.jpeg
|
||||||
|
var imgList embed.FS
|
||||||
|
|
||||||
|
//go:embed css/*.css
|
||||||
|
var cssList embed.FS
|
||||||
|
|
||||||
|
var pageMap = initPageMap()
|
||||||
|
var imgMap = initImgMap
|
||||||
|
var cssMap = initCssMap()
|
||||||
|
|
||||||
|
func initPageMap() map[string][]byte {
|
||||||
|
var pageMap = make(map[string][]byte, 8)
|
||||||
|
|
||||||
|
//login.html
|
||||||
|
data, err := pageList.ReadFile("login.html")
|
||||||
|
if err == nil {
|
||||||
|
pageMap["login.html"] = data
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func initImgMap() map[string][]byte {
|
||||||
|
var dataMap = make(map[string][]byte, 8)
|
||||||
|
|
||||||
|
//login.html
|
||||||
|
data, err := imgList.ReadFile("003.jpeg")
|
||||||
|
if err == nil {
|
||||||
|
dataMap["003.jpeg"] = data
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func initCssMap() map[string][]byte {
|
||||||
|
var dataMap = make(map[string][]byte, 8)
|
||||||
|
//login.html
|
||||||
|
data, err := cssList.ReadFile("login.css")
|
||||||
|
if err == nil {
|
||||||
|
dataMap["login.css"] = data
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataMap
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package apps
|
package static
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@ -6,20 +6,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func InitStaticGroup(g *echo.Group) {
|
func InitStaticGroup(g *echo.Group) {
|
||||||
|
|
||||||
g.GET("login.html", func(c echo.Context) error {
|
g.GET("login.html", func(c echo.Context) error {
|
||||||
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
|
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
c.Response().Header().Set("Cache-Control", "max-age=3600")
|
c.Response().Header().Set("Cache-Control", "max-age=3600")
|
||||||
return c.File("static/login.html")
|
|
||||||
|
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["login.html"])
|
||||||
})
|
})
|
||||||
|
|
||||||
g.GET("css/login.css", func(c echo.Context) error {
|
g.GET("css/login.css", func(c echo.Context) error {
|
||||||
c.Response().Header().Set("Cache-Control", "max-age=3600")
|
c.Response().Header().Set("Cache-Control", "max-age=3600")
|
||||||
return c.File("static/css/login.css")
|
return c.Blob(http.StatusOK, "text/html; charset=utf-8", cssMap["login.css"])
|
||||||
})
|
})
|
||||||
|
|
||||||
g.GET("img/003.jpeg", func(c echo.Context) error {
|
g.GET("img/003.jpeg", func(c echo.Context) error {
|
||||||
c.Response().Header().Set("Cache-Control", "max-age=3600")
|
c.Response().Header().Set("Cache-Control", "max-age=3600")
|
||||||
return c.File("static/img/003.jpeg")
|
return c.Blob(http.StatusOK, "text/html; charset=utf-8", cssMap["login.css"])
|
||||||
})
|
})
|
||||||
|
|
||||||
g.GET("/aa", func(c echo.Context) error {
|
g.GET("/aa", func(c echo.Context) error {
|
Loading…
x
Reference in New Issue
Block a user