fix: render template for addons and bootstrap pods

This commit is contained in:
Mikaël Cluseau
2019-12-26 11:10:23 +01:00
parent 49a16fe550
commit 1ee5d1c15a
4 changed files with 189 additions and 165 deletions

View File

@ -6,6 +6,7 @@ import (
"net"
"net/http"
"strings"
"text/template"
"github.com/emicklei/go-restful"
"novit.nc/direktil/local-server/pkg/mime"
@ -133,3 +134,17 @@ func wsError(resp *restful.Response, err error) {
http.StatusInternalServerError,
http.StatusText(http.StatusInternalServerError))
}
func wsRender(resp *restful.Response, tmplStr string, value interface{}) {
tmpl, err := template.New("wsRender").Funcs(templateFuncs).Parse(tmplStr)
if err != nil {
wsError(resp, err)
return
}
err = tmpl.Execute(resp, value)
if err != nil {
wsError(resp, err)
return
}
}