package static

import (
	"github.com/labstack/echo/v4"
	"net/http"
)

func InitStaticGroup(g *echo.Group) {

	g.GET("login.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["login.html"])
	})

	g.GET("css/login.css", func(c echo.Context) error {
		c.Response().Header().Set("Cache-Control", "max-age=3600")
		data, _ := cssMap["login.css"]
		return c.Blob(http.StatusOK, "text/css; charset=utf-8", data)
	})

	g.GET("img/003.jpeg", func(c echo.Context) error {
		c.Response().Header().Set("Cache-Control", "max-age=3600")
		return c.Blob(http.StatusOK, "image/jpeg", imgMap()["003.jpeg"])
	})

	g.GET("/aa", func(c echo.Context) error {
		c.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
		return c.String(http.StatusOK, `<p>html代码</p>`)
	})
}