From 401e6fc25f84da4e1c16f8373f68b251afc92e47 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 6 Mar 2026 22:03:48 +0000 Subject: [PATCH] Add fake API for proxying tile requests. --- api/routes.go | 1 + api/tile.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 api/tile.go diff --git a/api/routes.go b/api/routes.go index ff06383b..6740b389 100644 --- a/api/routes.go +++ b/api/routes.go @@ -22,6 +22,7 @@ func AddRoutes(r chi.Router) { r.Method("POST", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost)) r.Method("GET", "/leads", authenticatedHandlerJSON(listLead)) r.Method("POST", "/leads", authenticatedHandlerJSONPost(postLeads)) + r.Method("GET", "/tile//{z}/{y}/{x}", auth.NewEnsureAuth(getTile)) // Unauthenticated endpoints r.Get("/district", apiGetDistrict) diff --git a/api/tile.go b/api/tile.go new file mode 100644 index 00000000..3b96daa6 --- /dev/null +++ b/api/tile.go @@ -0,0 +1,33 @@ +package api + +import ( + "fmt" + "net/http" + "strconv" + + "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/go-chi/chi/v5" +) + +func getTile(w http.ResponseWriter, r *http.Request, org *models.Organization, user *models.User) { + x_str := chi.URLParam(r, "x") + y_str := chi.URLParam(r, "y") + z_str := chi.URLParam(r, "z") + + x, err := strconv.Atoi(x_str) + if err != nil { + http.Error(w, "can't parse x as an integer", http.StatusBadRequest) + return + } + y, err := strconv.Atoi(y_str) + if err != nil { + http.Error(w, "can't parse x as an integer", http.StatusBadRequest) + return + } + z, err := strconv.Atoi(z_str) + if err != nil { + http.Error(w, "can't parse x as an integer", http.StatusBadRequest) + return + } + fmt.Fprintf(w, "%d, %d, %d", x, y, z) +}