summaryrefslogtreecommitdiff
path: root/pkg/webui
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/webui')
-rw-r--r--pkg/webui/state.go7
-rw-r--r--pkg/webui/states.go3
-rw-r--r--pkg/webui/version.go11
3 files changed, 9 insertions, 12 deletions
diff --git a/pkg/webui/state.go b/pkg/webui/state.go
index 2ad1597..c12ee03 100644
--- a/pkg/webui/state.go
+++ b/pkg/webui/state.go
@@ -3,10 +3,10 @@ package webui
import (
"html/template"
"net/http"
- "strconv"
"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"))
@@ -19,9 +19,8 @@ func handleStateGET(db *database.DB) http.Handler {
Versions []model.Version
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- stateIdStr := r.PathValue("id")
- stateId, err := strconv.Atoi(stateIdStr)
- if err != nil {
+ var stateId uuid.UUID
+ if err := stateId.Parse(r.PathValue("id")); err != nil {
errorResponse(w, http.StatusBadRequest, err)
return
}
diff --git a/pkg/webui/states.go b/pkg/webui/states.go
index 85303fe..c68b2c9 100644
--- a/pkg/webui/states.go
+++ b/pkg/webui/states.go
@@ -7,7 +7,6 @@ import (
"net/http"
"net/url"
"path"
- "strconv"
"git.adyxax.org/adyxax/tfstated/pkg/database"
"git.adyxax.org/adyxax/tfstated/pkg/model"
@@ -87,7 +86,7 @@ func handleStatesPOST(db *database.DB) http.Handler {
})
return
}
- destination := path.Join("/version", strconv.Itoa(version.Id))
+ destination := path.Join("/version", version.Id.String())
http.Redirect(w, r, destination, http.StatusFound)
})
}
diff --git a/pkg/webui/version.go b/pkg/webui/version.go
index a577d5f..62a0e22 100644
--- a/pkg/webui/version.go
+++ b/pkg/webui/version.go
@@ -1,13 +1,13 @@
package webui
import (
- "fmt"
"html/template"
"net/http"
- "strconv"
+ "path"
"git.adyxax.org/adyxax/tfstated/pkg/database"
"git.adyxax.org/adyxax/tfstated/pkg/model"
+ "go.n16f.net/uuid"
)
var versionTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/version.html"))
@@ -21,9 +21,8 @@ func handleVersionGET(db *database.DB) http.Handler {
VersionData string
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- versionIdStr := r.PathValue("id")
- versionId, err := strconv.Atoi(versionIdStr)
- if err != nil {
+ var versionId uuid.UUID
+ if err := versionId.Parse(r.PathValue("id")); err != nil {
errorResponse(w, http.StatusBadRequest, err)
return
}
@@ -49,7 +48,7 @@ func handleVersionGET(db *database.DB) http.Handler {
versionData := string(version.Data[:])
render(w, versionTemplate, http.StatusOK, VersionsData{
Page: makePage(r, &Page{
- Precedent: fmt.Sprintf("/state/%d", state.Id),
+ Precedent: path.Join("/state/", state.Id.String()),
Section: "states",
Title: state.Path,
}),