groupware: add /bootstrap

* add a GET /accounts/{a}/boostrap URI that delivers the same as GET /
   but also mailboxes for a given account, in case the UI remembers the
   last used account identifier, to avoid an additional roundtrip

 * streamline the use of simpleError()

 * add logging of errors at the calling site

 * add logging of evictions of Sessions from the cache

 * change default Session cache TTL to 5min instead of 30sec
This commit is contained in:
Pascal Bleser
2025-08-21 15:27:45 +02:00
parent 42a4c5c156
commit 675e3e5fdb
17 changed files with 370 additions and 126 deletions

View File

@@ -2,6 +2,9 @@
package structs
import (
"maps"
"slices"
orderedmap "github.com/wk8/go-ordered-map"
)
@@ -30,3 +33,11 @@ func Uniq[T comparable](source []T) []T {
}
return set
}
func Keys[K comparable, V any](source map[K]V) []K {
if source == nil {
var zero []K
return zero
}
return slices.Collect(maps.Keys(source))
}

View File

@@ -83,3 +83,19 @@ func TestUniqWithStructs(t *testing.T) {
})
}
}
func TestKeys(t *testing.T) {
tests := []struct {
input map[int]string
expected []int
}{
{map[int]string{5: "cinq", 1: "un", 3: "trois", 4: "vier"}, []int{5, 1, 3, 4}},
{map[int]string{1: "un"}, []int{1}},
}
for i, tt := range tests {
t.Run(fmt.Sprintf("%d: testing %v", i+1, tt.input), func(t *testing.T) {
result := Keys(tt.input)
assert.ElementsMatch(t, tt.expected, result)
})
}
}