diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/config.go b/config.go old mode 100644 new mode 100755 diff --git a/go.mod b/go.mod old mode 100644 new mode 100755 diff --git a/go.sum b/go.sum old mode 100644 new mode 100755 diff --git a/handlers/api/api.go b/handlers/api/api.go old mode 100644 new mode 100755 diff --git a/handlers/api/cache.go b/handlers/api/cache.go old mode 100644 new mode 100755 index 433d7fc..ba72b72 --- a/handlers/api/cache.go +++ b/handlers/api/cache.go @@ -12,40 +12,58 @@ import ( func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) cacheid := vars["cacheid"] - - d, err := h.cache.Get(cacheid) - if err != nil { - fmt.Println(err) - w.WriteHeader(http.StatusNotFound) - return - } - - result := d - - if data, ok := d.([]any); ok { - if limitsmin, ok := r.URL.Query()["limits.min"]; ok { - min, _ := strconv.Atoi(limitsmin[0]) - if limitsmax, ok := r.URL.Query()["limits.max"]; ok { - max, _ := strconv.Atoi(limitsmax[0]) - if max > len(data) { - result = data[min:] - } else { - result = data[min:max] - } - } else { - result = data[min:] - } + // Use a channel to synchronize the goroutines + ch := make(chan []byte) + // Fetch data from cache asynchronously + go func() { + d, err := h.cache.Get(cacheid) + if err != nil { + fmt.Println(err) + w.WriteHeader(http.StatusNotFound) + ch <- nil + return } + var data []any + if val, ok := d.([]any); ok { + data = val + } else { + data = []any{d} + } + j := toJSON(data, w, r) + ch <- j // Signal that the data has been fetched successfully + close(ch) + }() + // wait for the JSON marshaling goroutine to finish + j := <-ch + if j == nil { + return // Stop processing if an error occurred } - - j, err := json.Marshal(result) - if err != nil { - w.WriteHeader(http.StatusNotFound) - return - } - + // Send the JSON response to the client w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") w.Write(j) + <-ch +} +func toJSON(data []any, w http.ResponseWriter, r *http.Request) []byte { + result := data + if limitsmin, ok := r.URL.Query()["limits.min"]; ok { + min, _ := strconv.Atoi(limitsmin[0]) + if limitsmax, ok := r.URL.Query()["limits.max"]; ok { + max, _ := strconv.Atoi(limitsmax[0]) + if max > len(data) { + result = data[min:] + } else { + result = data[min:max] + } + } else { + result = data[min:] + } + } + j, err := json.Marshal(result) + if err != nil { + w.WriteHeader(http.StatusNotFound) + return nil + } + return j } diff --git a/handlers/api/export.go b/handlers/api/export.go old mode 100644 new mode 100755 diff --git a/handlers/api/geo.go b/handlers/api/geo.go old mode 100644 new mode 100755 diff --git a/handlers/api/oidc.go b/handlers/api/oidc.go old mode 100644 new mode 100755 diff --git a/handlers/application/administration.go b/handlers/application/administration.go old mode 100644 new mode 100755 diff --git a/handlers/application/agenda.go b/handlers/application/agenda.go old mode 100644 new mode 100755 diff --git a/handlers/application/application.go b/handlers/application/application.go old mode 100644 new mode 100755 diff --git a/handlers/application/beneficiaries.go b/handlers/application/beneficiaries.go old mode 100644 new mode 100755 diff --git a/handlers/application/dashboard.go b/handlers/application/dashboard.go old mode 100644 new mode 100755 diff --git a/handlers/application/directory.go b/handlers/application/directory.go old mode 100644 new mode 100755 diff --git a/handlers/application/group.go b/handlers/application/group.go old mode 100644 new mode 100755 diff --git a/handlers/application/group_module.go b/handlers/application/group_module.go old mode 100644 new mode 100755 diff --git a/handlers/application/journeys.go b/handlers/application/journeys.go old mode 100644 new mode 100755 diff --git a/handlers/application/members.go b/handlers/application/members.go old mode 100644 new mode 100755 diff --git a/handlers/application/support.go b/handlers/application/support.go old mode 100644 new mode 100755 diff --git a/handlers/application/vehicles-management.go b/handlers/application/vehicles-management.go old mode 100644 new mode 100755 diff --git a/handlers/application/vehicles.go b/handlers/application/vehicles.go old mode 100644 new mode 100755 diff --git a/handlers/auth/auth.go b/handlers/auth/auth.go old mode 100644 new mode 100755 diff --git a/handlers/auth/disconnect.go b/handlers/auth/disconnect.go old mode 100644 new mode 100755 diff --git a/handlers/auth/groups.go b/handlers/auth/groups.go old mode 100644 new mode 100755 diff --git a/handlers/auth/lost_password.go b/handlers/auth/lost_password.go old mode 100644 new mode 100755 diff --git a/handlers/auth/onboarding.go b/handlers/auth/onboarding.go old mode 100644 new mode 100755 diff --git a/handlers/exports/agenda.go b/handlers/exports/agenda.go old mode 100644 new mode 100755 diff --git a/handlers/exports/exports.go b/handlers/exports/exports.go old mode 100644 new mode 100755 diff --git a/handlers/exports/fleets.go b/handlers/exports/fleets.go old mode 100644 new mode 100755 diff --git a/main.go b/main.go old mode 100644 new mode 100755 diff --git a/renderer/administration.go b/renderer/administration.go old mode 100644 new mode 100755 diff --git a/renderer/agenda.go b/renderer/agenda.go old mode 100644 new mode 100755 diff --git a/renderer/auth.go b/renderer/auth.go old mode 100644 new mode 100755 diff --git a/renderer/beneficiaries.go b/renderer/beneficiaries.go old mode 100644 new mode 100755 diff --git a/renderer/dashboard.go b/renderer/dashboard.go old mode 100644 new mode 100755 diff --git a/renderer/directory.go b/renderer/directory.go old mode 100644 new mode 100755 diff --git a/renderer/func-maps.go b/renderer/func-maps.go old mode 100644 new mode 100755 diff --git a/renderer/group.go b/renderer/group.go old mode 100644 new mode 100755 diff --git a/renderer/group_module.go b/renderer/group_module.go old mode 100644 new mode 100755 diff --git a/renderer/journeys.go b/renderer/journeys.go old mode 100644 new mode 100755 diff --git a/renderer/layout.go b/renderer/layout.go old mode 100644 new mode 100755 diff --git a/renderer/mailer.go b/renderer/mailer.go old mode 100644 new mode 100755 diff --git a/renderer/members.go b/renderer/members.go old mode 100644 new mode 100755 diff --git a/renderer/renderer.go b/renderer/renderer.go old mode 100644 new mode 100755 diff --git a/renderer/support.go b/renderer/support.go old mode 100644 new mode 100755 diff --git a/renderer/vehicle-management.go b/renderer/vehicle-management.go old mode 100644 new mode 100755 diff --git a/renderer/vehicles.go b/renderer/vehicles.go old mode 100644 new mode 100755 diff --git a/services/agenda.go b/services/agenda.go old mode 100644 new mode 100755 diff --git a/services/fleets.go b/services/fleets.go old mode 100644 new mode 100755 diff --git a/services/groupsmanagement.go b/services/groupsmanagement.go old mode 100644 new mode 100755 diff --git a/services/mobilityaccounts.go b/services/mobilityaccounts.go old mode 100644 new mode 100755 diff --git a/services/services.go b/services/services.go old mode 100644 new mode 100755 diff --git a/themes b/themes new file mode 160000 index 0000000..d6de19d --- /dev/null +++ b/themes @@ -0,0 +1 @@ +Subproject commit d6de19d8e238fec2f03957abdfa7b49a463d4a3c diff --git a/utils/form-validators/form-validators.go b/utils/form-validators/form-validators.go old mode 100644 new mode 100755 diff --git a/utils/form-validators/phone-numbers.go b/utils/form-validators/phone-numbers.go old mode 100644 new mode 100755 diff --git a/utils/icons/svg-icons.go b/utils/icons/svg-icons.go old mode 100644 new mode 100755 diff --git a/utils/identification/groups.go b/utils/identification/groups.go old mode 100644 new mode 100755 diff --git a/utils/identification/oidc.go b/utils/identification/oidc.go old mode 100644 new mode 100755 diff --git a/utils/profile-pictures/profile-pictures.go b/utils/profile-pictures/profile-pictures.go old mode 100644 new mode 100755 diff --git a/utils/sorting/beneficiaries.go b/utils/sorting/beneficiaries.go old mode 100644 new mode 100755 diff --git a/utils/sorting/events.go b/utils/sorting/events.go old mode 100644 new mode 100755 diff --git a/utils/sorting/fleets.go b/utils/sorting/fleets.go old mode 100644 new mode 100755 diff --git a/utils/sorting/groups.go b/utils/sorting/groups.go old mode 100644 new mode 100755 diff --git a/utils/sorting/sorting.go b/utils/sorting/sorting.go old mode 100644 new mode 100755 diff --git a/utils/storage/cache.go b/utils/storage/cache.go old mode 100644 new mode 100755 diff --git a/utils/storage/etcd.go b/utils/storage/etcd.go old mode 100644 new mode 100755 index 14d044d..fb4512a --- a/utils/storage/etcd.go +++ b/utils/storage/etcd.go @@ -74,6 +74,7 @@ func NewEtcdHandler(cfg *viper.Viper) (*EtcdHandler, error) { Password: password, DialTimeout: 5 * time.Second, }) + fmt.Println(endpoints,prefix,username,password) if err != nil { fmt.Println(err) return nil, err diff --git a/utils/storage/files.go b/utils/storage/files.go old mode 100644 new mode 100755 diff --git a/utils/storage/kv.go b/utils/storage/kv.go old mode 100644 new mode 100755 diff --git a/utils/storage/minio.go b/utils/storage/minio.go old mode 100644 new mode 100755 diff --git a/utils/storage/sessions.go b/utils/storage/sessions.go old mode 100644 new mode 100755