feat(webui): bootstrap session handling and login process
This commit is contained in:
parent
63e2b1b09d
commit
6e069484cb
18 changed files with 447 additions and 1 deletions
22
pkg/webui/render.go
Normal file
22
pkg/webui/render.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package webui
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func render(w http.ResponseWriter, t *template.Template, status int, data any) {
|
||||
var buf bytes.Buffer
|
||||
if err := t.ExecuteTemplate(&buf, "base.html", data); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, _ = w.Write([]byte(fmt.Sprintf(
|
||||
"%s: failed to execute template: %+v",
|
||||
http.StatusText(http.StatusInternalServerError),
|
||||
err)))
|
||||
} else {
|
||||
w.WriteHeader(status)
|
||||
_, _ = buf.WriteTo(w)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue