From cdf3bf115f74a71c9ff0292242a5f01385aa1a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 24 Jul 2021 16:03:12 +0200 Subject: [PATCH] embed swal2 as static html file. --- internal/utils/swal2.go | 298 +++----------------------------------- internal/utils/swal2.html | 282 ++++++++++++++++++++++++++++++++++++ 2 files changed, 300 insertions(+), 280 deletions(-) create mode 100644 internal/utils/swal2.html 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 +
+ + + +