Files
neko-rooms/internal/utils/swal2.go
T
Miroslav Šedivý a6169da135 interface{} to any.
2023-11-25 22:54:35 +01:00

28 lines
460 B
Go

package utils
import (
_ "embed"
"html/template"
"net/http"
)
//go:embed swal2.html
var swal2Template string
func Swal2Response(w http.ResponseWriter, body string) {
w.Header().Set("Content-Type", "text/html")
tmpl, err := template.New("main").Parse(swal2Template)
if err != nil {
http.Error(w, err.Error(), 500)
}
err = tmpl.Execute(w, map[string]any{
"Body": template.HTML(body),
})
if err != nil {
http.Error(w, err.Error(), 500)
}
}