Add fake API for proxying tile requests.
This commit is contained in:
parent
502a4d15df
commit
401e6fc25f
2 changed files with 34 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
33
api/tile.go
Normal file
33
api/tile.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue