rewrite using net/http
tronnet/workflows: Static Analysis -- Golang / static-go (push) Failing after 6s

This commit is contained in:
alu committed 2026-10-22 18:58:14 +00:00
1 parent db8ed2e830
commit 9b3ec1221e
8 files changed
+268 -148

No files matched your search

+17 -6
View File
@@ -1,6 +1,7 @@
package routes
import (
"bytes"
"fmt"
"net/http"
paas "proxmoxaas-common-lib"
@@ -40,29 +41,39 @@ var Green = color.RGB{
B: 0,
}
func HandleGETAccount(c *gin.Context) {
auth, err := common.GetAuthFromRequest(c)
func HandleGETAccount(w http.ResponseWriter, r *http.Request) {
auth, err := common.GetAuthFromRequest(r)
if err == nil {
user, err := GetUserBasic(auth)
if err != nil {
common.HandleNonFatalError(c, err)
common.HandleNonFatalError(w, err)
return
}
pools, err := GetUserPools(auth)
if err != nil {
common.HandleNonFatalError(c, err)
common.HandleNonFatalError(w, err)
return
}
c.HTML(http.StatusOK, "html/account.html", gin.H{
w.Header().Set("Content-Type", "text/html")
body := bytes.Buffer{}
err = common.TMPL.ExecuteTemplate(&body, "html/account.html", gin.H{
"global": common.Global,
"page": "account",
"user": user,
"pools": pools,
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
} else {
w.Write(body.Bytes())
return
}
} else {
c.Redirect(http.StatusFound, "/login") // if user is not authed, redirect user to login page
http.Redirect(w, r, "/login", http.StatusFound) // if user is not authed, redirect user to login page
return
}
}