feat: resource list and table output formatter

This commit is contained in:
2025-07-20 19:22:36 +02:00
parent 45712dacf6
commit 4a15a4db66
16 changed files with 209 additions and 40 deletions

View File

@ -24,7 +24,7 @@ const (
paramLocation = "location"
)
func (h *DishesHandler) Get(ctx context.Context, params params.Container) ([]any, error) {
func (h *DishesHandler) Get(ctx context.Context, params params.Container) (*interfaces.ResourceList, error) {
// Read parameters
p, err := params.GetValue(paramDate)
if err != nil {
@ -55,14 +55,17 @@ func (h *DishesHandler) Get(ctx context.Context, params params.Container) ([]any
}
// Return
return util.Transform(*dishes, func(i *stwbremen.Dish) any {
d, err := resources.DishFromDTO(*i)
if err != nil {
return resources.Dish{}
}
return &interfaces.ResourceList{
ItemKind: resources.ResourceDish,
Items: util.Transform(*dishes, func(i *stwbremen.Dish) interfaces.Resource {
d, err := resources.DishFromDTO(*i)
if err != nil {
return &resources.Dish{}
}
return *d
}), nil
return d
}),
}, nil
}