File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ package server
2222import (
2323"html/template"
2424"io/fs"
25+ "os"
2526
2627brotli "github.com/anargu/gin-brotli"
2728"github.com/apache/answer/internal/base/middleware"
@@ -53,9 +54,14 @@ func NewHTTPServer(debug bool,
5354r .Use (brotli .Brotli (brotli .DefaultCompression ), middleware .ExtractAndSetAcceptLanguage , shortIDMiddleware .SetShortIDFlag ())
5455r .GET ("/healthz" , func (ctx * gin.Context ) { ctx .String (200 , "OK" ) })
5556
56- html , _ := fs .Sub (ui .Template , "template" )
57- htmlTemplate := template .Must (template .New ("" ).Funcs (funcMap ).ParseFS (html , "*" ))
58- r .SetHTMLTemplate (htmlTemplate )
57+ templatePath := os .Getenv ("ANSWER_TEMPLATE_PATH" )
58+ if templatePath != "" {
59+ r .LoadHTMLGlob (templatePath )
60+ } else {
61+ html , _ := fs .Sub (ui .Template , "template" )
62+ htmlTemplate := template .Must (template .New ("" ).Funcs (funcMap ).ParseFS (html , "*" ))
63+ r .SetHTMLTemplate (htmlTemplate )
64+ }
5965r .Use (middleware .HeadersByRequestURI ())
6066viewRouter .Register (r , uiConf .BaseURL )
6167
You can’t perform that action at this time.
0 commit comments