diff --git a/backend/services/controller/internal/api/api.go b/backend/services/controller/internal/api/api.go index 4046436..404e900 100644 --- a/backend/services/controller/internal/api/api.go +++ b/backend/services/controller/internal/api/api.go @@ -57,6 +57,13 @@ func (a *Api) StartApi() { authentication.HandleFunc("/password", a.changePassword).Methods("PUT") authentication.HandleFunc("/admin/register", a.registerAdminUser).Methods("POST") authentication.HandleFunc("/admin/exists", a.adminUserExists).Methods("GET") + if a.enterpise.Enable { + mapRoutes := r.PathPrefix("/api/map").Subrouter() + mapRoutes.HandleFunc("", a.devicesLocation).Methods("GET") + mapRoutes.Use(func(handler http.Handler) http.Handler { + return middleware.Middleware(handler) + }) + } iot := r.PathPrefix("/api/device").Subrouter() iot.HandleFunc("/alias", a.setDeviceAlias).Methods("PUT") iot.HandleFunc("/auth", a.deviceAuth).Methods("GET", "POST", "DELETE") diff --git a/backend/services/controller/internal/api/enterprise.go b/backend/services/controller/internal/api/enterprise.go index f7ce633..1e09d44 100644 --- a/backend/services/controller/internal/api/enterprise.go +++ b/backend/services/controller/internal/api/enterprise.go @@ -28,6 +28,22 @@ func (a *Api) getEnterpriseResource( return err } +func (a *Api) getMapsResource( + action string, + w http.ResponseWriter, + body []byte, +) error { + + err := bridge.NatsEnterpriseInteraction("geolocation.v1."+action, body, w, a.nc) + return err +} + +func (a *Api) devicesLocation(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodGet { + a.getMapsResource("get", w, []byte{}) + } +} + func (a *Api) deviceSiteSurvey(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) sn := vars["sn"]