busybar / internal / controllers / helpers.go
helpers.go
Raw
package controllers

import (
	"github.com/labstack/echo/v4"
)

type envelope map[string]any

func getInput[T any](c echo.Context) (*T, error) {
	input := new(T)

	if err := c.Bind(input); err != nil {
		return nil, err
	}

	if err := c.Validate(input); err != nil {
		return nil, err
	}

	return input, nil
}