feat(controller): add maps api
This commit is contained in:
parent
99508c5f16
commit
266857187e
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user