diff options
author | Julien Dessaux | 2025-02-23 22:06:46 +0100 |
---|---|---|
committer | Julien Dessaux | 2025-02-23 22:06:46 +0100 |
commit | a83296b79ac7eb851a44600fb7ccf6c1a200e2bc (patch) | |
tree | 25d69d9c8a0b4905761d6089acacc454fecf55dd /pkg/webui/state.go | |
parent | chore(tfstated): change database state id and version id formats to uuidv7 (diff) | |
download | tfstated-a83296b79ac7eb851a44600fb7ccf6c1a200e2bc.tar.gz tfstated-a83296b79ac7eb851a44600fb7ccf6c1a200e2bc.tar.bz2 tfstated-a83296b79ac7eb851a44600fb7ccf6c1a200e2bc.zip |
[webui] refactored states and versions routes
Diffstat (limited to 'pkg/webui/state.go')
-rw-r--r-- | pkg/webui/state.go | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/pkg/webui/state.go b/pkg/webui/state.go deleted file mode 100644 index c12ee03..0000000 --- a/pkg/webui/state.go +++ /dev/null @@ -1,53 +0,0 @@ -package webui - -import ( - "html/template" - "net/http" - - "git.adyxax.org/adyxax/tfstated/pkg/database" - "git.adyxax.org/adyxax/tfstated/pkg/model" - "go.n16f.net/uuid" -) - -var stateTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/state.html")) - -func handleStateGET(db *database.DB) http.Handler { - type StatesData struct { - Page *Page - State *model.State - Usernames map[string]string - Versions []model.Version - } - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - var stateId uuid.UUID - if err := stateId.Parse(r.PathValue("id")); err != nil { - errorResponse(w, http.StatusBadRequest, err) - return - } - state, err := db.LoadStateById(stateId) - if err != nil { - errorResponse(w, http.StatusInternalServerError, err) - return - } - versions, err := db.LoadVersionsByState(state) - if err != nil { - errorResponse(w, http.StatusInternalServerError, err) - return - } - usernames, err := db.LoadAccountUsernames() - if err != nil { - errorResponse(w, http.StatusInternalServerError, err) - return - } - render(w, stateTemplate, http.StatusOK, StatesData{ - Page: makePage(r, &Page{ - Precedent: "/states", - Section: "states", - Title: state.Path, - }), - State: state, - Usernames: usernames, - Versions: versions, - }) - }) -} |