mirror of https://gitee.com/answerdev/answer.git
fix dev code
This commit is contained in:
parent
4c354090c7
commit
4fd208ba46
|
@ -3,7 +3,6 @@ package server
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
|
||||||
|
|
||||||
brotli "github.com/anargu/gin-brotli"
|
brotli "github.com/anargu/gin-brotli"
|
||||||
"github.com/answerdev/answer/internal/base/middleware"
|
"github.com/answerdev/answer/internal/base/middleware"
|
||||||
|
@ -32,15 +31,9 @@ func NewHTTPServer(debug bool,
|
||||||
r.Use(brotli.Brotli(brotli.DefaultCompression))
|
r.Use(brotli.Brotli(brotli.DefaultCompression))
|
||||||
r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK") })
|
r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK") })
|
||||||
|
|
||||||
dev := os.Getenv("DEVCODE")
|
html, _ := fs.Sub(ui.Template, "template")
|
||||||
if dev != "" {
|
htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*"))
|
||||||
r.SetFuncMap(funcMap)
|
r.SetHTMLTemplate(htmlTemplate)
|
||||||
r.LoadHTMLGlob("../../ui/template/*")
|
|
||||||
} else {
|
|
||||||
html, _ := fs.Sub(ui.Template, "template")
|
|
||||||
htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*"))
|
|
||||||
r.SetHTMLTemplate(htmlTemplate)
|
|
||||||
}
|
|
||||||
|
|
||||||
viewRouter.Register(r)
|
viewRouter.Register(r)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue