feat: resource list and table output formatter
This commit is contained in:
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user