mylomen-server/static/static_router.go
shaoyongjun 8d6354c239 to:sync
2024-10-28 22:28:43 +08:00

89 lines
2.8 KiB
Go

package static
import (
"github.com/labstack/echo/v4"
"net/http"
)
func Favicon(c echo.Context) error {
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "image/png", imgMap["favicon.ico"])
}
func Login(c echo.Context) error {
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["mylomen.html"])
}
func Note(c echo.Context) error {
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
c.Response().Header().Set("Cache-Control", "max-age=1")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["yanxuelu.html"])
}
func Chat(c echo.Context) error {
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["ai-chat.html"])
}
func Chat1(c echo.Context) error {
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["ai-chat1.html"])
}
func Chat2(c echo.Context) error {
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["ai-chat2.html"])
}
func Chat3(c echo.Context) error {
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
c.Response().Header().Set("Cache-Control", "max-age=1")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["index_ollama.html"])
}
func InitStaticGroup(g *echo.Group) {
g.GET("mylomen.html", func(c echo.Context) error {
c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "text/html; charset=utf-8", pageMap["mylomen.html"])
})
g.GET("css/:name", func(c echo.Context) error {
cssName := c.Param("name")
c.Response().Header().Set("Cache-Control", "max-age=1")
data, _ := cssMap[cssName]
return c.Blob(http.StatusOK, "text/css; charset=utf-8", data)
})
g.GET("img/:name", func(c echo.Context) error {
imgName := c.Param("name")
c.Response().Header().Set("Cache-Control", "max-age=3600")
return c.Blob(http.StatusOK, "image/jpeg", imgMap[imgName])
})
g.GET("js/:name", func(c echo.Context) error {
jsName := c.Param("name")
c.Response().Header().Set("Cache-Control", "max-age=1")
return c.Blob(http.StatusOK, "text/javaScript", jsMap[jsName])
})
g.GET("page/:name", func(c echo.Context) error {
pageName := c.Param("name")
c.Response().Header().Set("Cache-Control", "max-age=3600")
data, _ := pageMap[pageName]
return c.Blob(http.StatusOK, "text/html; charset=utf-8", data)
})
}