From 4858286bd67b24e02dc020195ac705ce1e836d13 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 27 Oct 2023 20:50:27 -0600 Subject: [PATCH] move api to /api/* --- cmd/clitest/index.html | 4 ++-- cmd/clitest/main.go | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/clitest/index.html b/cmd/clitest/index.html index cbe25a2..c7939a8 100644 --- a/cmd/clitest/index.html +++ b/cmd/clitest/index.html @@ -17,12 +17,12 @@ function callback(responseBody, responseStatus) { } function draw(form) { - path = "/bal" + path = "/api/bal" query = "?x=y" Array.from(form.elements).forEach((input) => { query += "&" + input.name + "=" + input.value; if (input.name == "mode") { - path = "/" + input.value; + path = "/api/" + input.value; } }); console.log(path, query); diff --git a/cmd/clitest/main.go b/cmd/clitest/main.go index ad764a0..31ea29b 100644 --- a/cmd/clitest/main.go +++ b/cmd/clitest/main.go @@ -9,6 +9,7 @@ import ( "maps" "net/http" "os" + "path" "slices" "sort" "strconv" @@ -64,9 +65,9 @@ func main() { like = append(like, ledger.LikeAfter(*likeAfter)) foo := func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case "/bal", "/reg": - case "/ui": + switch path.Dir(r.URL.Path) { + case "/api": + case "/": f, err := os.Open("./index.html") if err != nil { panic(err) @@ -281,9 +282,9 @@ func main() { } return chart } - primary := toChart(r.URL.Path == "/bal", r.URL.Query().Get("chart"), register) + primary := toChart(r.URL.Path == "/api/bal", r.URL.Query().Get("chart"), register) if len(predicted) > 0 { - primary.Overlap(toChart(r.URL.Path == "/bal", "line", predicted)) + primary.Overlap(toChart(r.URL.Path == "/api/bal", "line", predicted)) } if err := primary.Render(w); err != nil { panic(err)