feat: get handlers return object slices
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package menu
|
||||
package dishes
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/util"
|
||||
)
|
||||
|
||||
type MenuHandler struct {
|
||||
type DishesHandler struct {
|
||||
interfaces.ResourceHandler
|
||||
interfaces.GetHandler
|
||||
|
||||
@ -24,7 +24,7 @@ const (
|
||||
paramLocation = "location"
|
||||
)
|
||||
|
||||
func (h *MenuHandler) Get(ctx context.Context, params params.Container) (any, error) {
|
||||
func (h *DishesHandler) Get(ctx context.Context, params params.Container) ([]any, error) {
|
||||
// Read parameters
|
||||
p, err := params.GetValue(paramDate)
|
||||
if err != nil {
|
||||
@ -55,20 +55,18 @@ func (h *MenuHandler) Get(ctx context.Context, params params.Container) (any, er
|
||||
}
|
||||
|
||||
// Return
|
||||
return &resources.Menu{
|
||||
Location: location.(string),
|
||||
Dishes: util.Transform(*dishes, func(i *stwbremen.Dish) resources.Dish {
|
||||
d, err := resources.DishFromDTO(*i)
|
||||
if err != nil {
|
||||
return resources.Dish{}
|
||||
}
|
||||
return util.Transform(*dishes, func(i *stwbremen.Dish) any {
|
||||
d, err := resources.DishFromDTO(*i)
|
||||
if err != nil {
|
||||
return resources.Dish{}
|
||||
}
|
||||
|
||||
return *d
|
||||
}), nil
|
||||
|
||||
return *d
|
||||
}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *MenuHandler) GetParametersForVerb(verb interfaces.Verb) []params.Registration {
|
||||
func (h *DishesHandler) GetParametersForVerb(verb interfaces.Verb) []params.Registration {
|
||||
return []params.Registration{
|
||||
{
|
||||
Name: paramDate,
|
||||
Reference in New Issue
Block a user