solidarity-transport-2 #2
0
Dockerfile
Normal file → Executable file
0
Dockerfile
Normal file → Executable file
0
handlers/api/api.go
Normal file → Executable file
0
handlers/api/api.go
Normal file → Executable file
78
handlers/api/cache.go
Normal file → Executable file
78
handlers/api/cache.go
Normal file → Executable file
@@ -12,40 +12,58 @@ import (
|
|||||||
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
|
func (h APIHandler) GetCache(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
cacheid := vars["cacheid"]
|
cacheid := vars["cacheid"]
|
||||||
|
// Use a channel to synchronize the goroutines
|
||||||
d, err := h.cache.Get(cacheid)
|
ch := make(chan []byte)
|
||||||
if err != nil {
|
// Fetch data from cache asynchronously
|
||||||
fmt.Println(err)
|
go func() {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
d, err := h.cache.Get(cacheid)
|
||||||
return
|
if err != nil {
|
||||||
}
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
result := d
|
ch <- nil
|
||||||
|
return
|
||||||
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:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
// Send the JSON response to the client
|
||||||
j, err := json.Marshal(result)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(j)
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
0
handlers/api/export.go
Normal file → Executable file
0
handlers/api/export.go
Normal file → Executable file
0
handlers/api/geo.go
Normal file → Executable file
0
handlers/api/geo.go
Normal file → Executable file
0
handlers/api/oidc.go
Normal file → Executable file
0
handlers/api/oidc.go
Normal file → Executable file
0
handlers/application/administration.go
Normal file → Executable file
0
handlers/application/administration.go
Normal file → Executable file
0
handlers/application/agenda.go
Normal file → Executable file
0
handlers/application/agenda.go
Normal file → Executable file
0
handlers/application/application.go
Normal file → Executable file
0
handlers/application/application.go
Normal file → Executable file
0
handlers/application/beneficiaries.go
Normal file → Executable file
0
handlers/application/beneficiaries.go
Normal file → Executable file
0
handlers/application/dashboard.go
Normal file → Executable file
0
handlers/application/dashboard.go
Normal file → Executable file
0
handlers/application/directory.go
Normal file → Executable file
0
handlers/application/directory.go
Normal file → Executable file
0
handlers/application/group.go
Normal file → Executable file
0
handlers/application/group.go
Normal file → Executable file
0
handlers/application/group_module.go
Normal file → Executable file
0
handlers/application/group_module.go
Normal file → Executable file
0
handlers/application/journeys.go
Normal file → Executable file
0
handlers/application/journeys.go
Normal file → Executable file
0
handlers/application/members.go
Normal file → Executable file
0
handlers/application/members.go
Normal file → Executable file
0
handlers/application/support.go
Normal file → Executable file
0
handlers/application/support.go
Normal file → Executable file
0
handlers/application/vehicles-management.go
Normal file → Executable file
0
handlers/application/vehicles-management.go
Normal file → Executable file
0
handlers/application/vehicles.go
Normal file → Executable file
0
handlers/application/vehicles.go
Normal file → Executable file
0
handlers/auth/auth.go
Normal file → Executable file
0
handlers/auth/auth.go
Normal file → Executable file
0
handlers/auth/disconnect.go
Normal file → Executable file
0
handlers/auth/disconnect.go
Normal file → Executable file
0
handlers/auth/groups.go
Normal file → Executable file
0
handlers/auth/groups.go
Normal file → Executable file
0
handlers/auth/lost_password.go
Normal file → Executable file
0
handlers/auth/lost_password.go
Normal file → Executable file
0
handlers/auth/onboarding.go
Normal file → Executable file
0
handlers/auth/onboarding.go
Normal file → Executable file
0
handlers/exports/agenda.go
Normal file → Executable file
0
handlers/exports/agenda.go
Normal file → Executable file
0
handlers/exports/exports.go
Normal file → Executable file
0
handlers/exports/exports.go
Normal file → Executable file
0
handlers/exports/fleets.go
Normal file → Executable file
0
handlers/exports/fleets.go
Normal file → Executable file
0
renderer/administration.go
Normal file → Executable file
0
renderer/administration.go
Normal file → Executable file
0
renderer/agenda.go
Normal file → Executable file
0
renderer/agenda.go
Normal file → Executable file
0
renderer/auth.go
Normal file → Executable file
0
renderer/auth.go
Normal file → Executable file
0
renderer/beneficiaries.go
Normal file → Executable file
0
renderer/beneficiaries.go
Normal file → Executable file
0
renderer/dashboard.go
Normal file → Executable file
0
renderer/dashboard.go
Normal file → Executable file
0
renderer/directory.go
Normal file → Executable file
0
renderer/directory.go
Normal file → Executable file
0
renderer/func-maps.go
Normal file → Executable file
0
renderer/func-maps.go
Normal file → Executable file
0
renderer/group.go
Normal file → Executable file
0
renderer/group.go
Normal file → Executable file
0
renderer/group_module.go
Normal file → Executable file
0
renderer/group_module.go
Normal file → Executable file
0
renderer/journeys.go
Normal file → Executable file
0
renderer/journeys.go
Normal file → Executable file
0
renderer/layout.go
Normal file → Executable file
0
renderer/layout.go
Normal file → Executable file
0
renderer/mailer.go
Normal file → Executable file
0
renderer/mailer.go
Normal file → Executable file
0
renderer/members.go
Normal file → Executable file
0
renderer/members.go
Normal file → Executable file
0
renderer/renderer.go
Normal file → Executable file
0
renderer/renderer.go
Normal file → Executable file
0
renderer/support.go
Normal file → Executable file
0
renderer/support.go
Normal file → Executable file
0
renderer/vehicle-management.go
Normal file → Executable file
0
renderer/vehicle-management.go
Normal file → Executable file
0
renderer/vehicles.go
Normal file → Executable file
0
renderer/vehicles.go
Normal file → Executable file
0
services/agenda.go
Normal file → Executable file
0
services/agenda.go
Normal file → Executable file
0
services/fleets.go
Normal file → Executable file
0
services/fleets.go
Normal file → Executable file
0
services/groupsmanagement.go
Normal file → Executable file
0
services/groupsmanagement.go
Normal file → Executable file
0
services/mobilityaccounts.go
Normal file → Executable file
0
services/mobilityaccounts.go
Normal file → Executable file
0
services/services.go
Normal file → Executable file
0
services/services.go
Normal file → Executable file
1
themes
Submodule
1
themes
Submodule
Submodule themes added at d6de19d8e2
0
utils/form-validators/form-validators.go
Normal file → Executable file
0
utils/form-validators/form-validators.go
Normal file → Executable file
0
utils/form-validators/phone-numbers.go
Normal file → Executable file
0
utils/form-validators/phone-numbers.go
Normal file → Executable file
0
utils/icons/svg-icons.go
Normal file → Executable file
0
utils/icons/svg-icons.go
Normal file → Executable file
0
utils/identification/groups.go
Normal file → Executable file
0
utils/identification/groups.go
Normal file → Executable file
0
utils/identification/oidc.go
Normal file → Executable file
0
utils/identification/oidc.go
Normal file → Executable file
0
utils/profile-pictures/profile-pictures.go
Normal file → Executable file
0
utils/profile-pictures/profile-pictures.go
Normal file → Executable file
0
utils/sorting/beneficiaries.go
Normal file → Executable file
0
utils/sorting/beneficiaries.go
Normal file → Executable file
0
utils/sorting/events.go
Normal file → Executable file
0
utils/sorting/events.go
Normal file → Executable file
0
utils/sorting/fleets.go
Normal file → Executable file
0
utils/sorting/fleets.go
Normal file → Executable file
0
utils/sorting/groups.go
Normal file → Executable file
0
utils/sorting/groups.go
Normal file → Executable file
0
utils/sorting/sorting.go
Normal file → Executable file
0
utils/sorting/sorting.go
Normal file → Executable file
0
utils/storage/cache.go
Normal file → Executable file
0
utils/storage/cache.go
Normal file → Executable file
1
utils/storage/etcd.go
Normal file → Executable file
1
utils/storage/etcd.go
Normal file → Executable file
@@ -74,6 +74,7 @@ func NewEtcdHandler(cfg *viper.Viper) (*EtcdHandler, error) {
|
|||||||
Password: password,
|
Password: password,
|
||||||
DialTimeout: 5 * time.Second,
|
DialTimeout: 5 * time.Second,
|
||||||
})
|
})
|
||||||
|
fmt.Println(endpoints,prefix,username,password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
0
utils/storage/files.go
Normal file → Executable file
0
utils/storage/files.go
Normal file → Executable file
0
utils/storage/kv.go
Normal file → Executable file
0
utils/storage/kv.go
Normal file → Executable file
0
utils/storage/minio.go
Normal file → Executable file
0
utils/storage/minio.go
Normal file → Executable file
0
utils/storage/sessions.go
Normal file → Executable file
0
utils/storage/sessions.go
Normal file → Executable file
Reference in New Issue
Block a user