Add fake API for proxying tile requests.

This commit is contained in:
Eli Ribble 2026-03-06 22:03:48 +00:00
parent 502a4d15df
commit 401e6fc25f
No known key found for this signature in database
2 changed files with 34 additions and 0 deletions

View file

@ -22,6 +22,7 @@ func AddRoutes(r chi.Router) {
r.Method("POST", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost)) r.Method("POST", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost))
r.Method("GET", "/leads", authenticatedHandlerJSON(listLead)) r.Method("GET", "/leads", authenticatedHandlerJSON(listLead))
r.Method("POST", "/leads", authenticatedHandlerJSONPost(postLeads)) r.Method("POST", "/leads", authenticatedHandlerJSONPost(postLeads))
r.Method("GET", "/tile//{z}/{y}/{x}", auth.NewEnsureAuth(getTile))
// Unauthenticated endpoints // Unauthenticated endpoints
r.Get("/district", apiGetDistrict) r.Get("/district", apiGetDistrict)

33
api/tile.go Normal file
View file

@ -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)
}