diff --git a/internal/utils/swal2.go b/internal/utils/swal2.go index 1b8876d..2bd9d09 100644 --- a/internal/utils/swal2.go +++ b/internal/utils/swal2.go @@ -1,289 +1,27 @@ package utils -import "net/http" +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") - html := ` - - - - -Neko rooms - - - - - - - -
- ` + body + ` - Powered by: neko-rooms -
+ tmpl, err := template.New("main").Parse(swal2Template) + if err != nil { + http.Error(w, err.Error(), 500) + } -` + err = tmpl.Execute(w, map[string]interface{}{ + "Body": template.HTML(body), + }) - w.Write([]byte(html)) + if err != nil { + http.Error(w, err.Error(), 500) + } } diff --git a/internal/utils/swal2.html b/internal/utils/swal2.html new file mode 100644 index 0000000..b706414 --- /dev/null +++ b/internal/utils/swal2.html @@ -0,0 +1,282 @@ + + + + + + +Neko rooms + + + + + + + +
+ {{.Body}} + Powered by: neko-rooms +
+ + + +