Documentation ¶
Index ¶
- func Delete(c Container, config CrudConfig) fiber.Handler
- func Get(c Container, config CrudConfig) fiber.Handler
- func Post(c Container, config CrudConfig) fiber.Handler
- func Put(c Container, config CrudConfig) fiber.Handler
- func RegisterCrudRoutes(router fiber.Router, c Container)
- type Container
- type CrudConfig
- type CrudContainer
- type CrudRepository
- type Database
- type DatabaseFilter
- type Entry
- type Error
- type Repo
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(c Container, config CrudConfig) fiber.Handler
func Get ¶
func Get(c Container, config CrudConfig) fiber.Handler
func Post ¶
func Post(c Container, config CrudConfig) fiber.Handler
func Put ¶
func Put(c Container, config CrudConfig) fiber.Handler
func RegisterCrudRoutes ¶
func RegisterCrudRoutes(router fiber.Router, c Container)
RegisterCrudRoutes register all crud routes based on their configuration
Types ¶
type Container ¶
type Container interface { GetCrudConfigs() []CrudConfig GetLogger() logging.Logger GetDatabase() Database GetCrudRepo() CrudRepository }
Container service container interface
type CrudConfig ¶
type CrudConfig interface { UseContainer(c Container) GetEntityEntry() interface{} GetBasePath() string CreateGetFilter(ctx *fiber.Ctx) DatabaseFilter CreateUpdateFilter(ctx *fiber.Ctx) DatabaseFilter CreateDeleteFilter(ctx *fiber.Ctx) DatabaseFilter SerializeList(entries []interface{}, ctx *fiber.Ctx, tx *storage.Transaction) (serialized interface{}, err error) MapPostEntry(entry interface{}, ctx *fiber.Ctx, tx *storage.Transaction) (mapped Entry, err error) MapPutEntry(entry interface{}, ctx *fiber.Ctx, tx *storage.Transaction) (mapped Entry, err error) }
CrudConfig configuration of a crud api for an entity
type CrudContainer ¶
type CrudContainer struct {
// contains filtered or unexported fields
}
CrudContainer is a basic service container that can be used with gocruddy
func (*CrudContainer) GetCrudConfigs ¶
func (c *CrudContainer) GetCrudConfigs() []CrudConfig
GetCrudConfigs return all registered crud configurations
func (*CrudContainer) UseCrudConfig ¶
func (c *CrudContainer) UseCrudConfig(crud CrudConfig)
UseCrudConfig register a crud configuration
type CrudRepository ¶
type CrudRepository interface { Repo GetAllEntries(tx *storage.Transaction, filter DatabaseFilter, t interface{}) (entries []interface{}, err error) GetByID(tx *storage.Transaction, id uint, filter DatabaseFilter, t interface{}) (entry interface{}, err error) }
type Database ¶
type Database interface { UseTransaction(fn storage.HandlerFunc) error Gorm() *gorm.DB Begin() (tx *storage.Transaction, err error) }
Database interface
type DatabaseFilter ¶
DatabaseFilter a function that filters a database query
type Repo ¶
type Repo interface { Insert(tx *storage.Transaction, entry interface{}) (err error) Update(tx *storage.Transaction, entry interface{}) (err error) Delete(tx *storage.Transaction, entry interface{}) (err error) Remove(tx *storage.Transaction, entry interface{}) (err error) }
type Repository ¶
type Repository struct {
storage.Repository
}
Repository crud data repository
func (*Repository) GetAllEntries ¶
func (r *Repository) GetAllEntries(tx *storage.Transaction, filter DatabaseFilter, t interface{}) (entries []interface{}, err error)
GetAllEntries returns all entities matching a filter
func (*Repository) GetByID ¶
func (r *Repository) GetByID(tx *storage.Transaction, id uint, filter DatabaseFilter, t interface{}) (entry interface{}, err error)
GetByID fetches an entity by its unique id
Source Files ¶
Click to show internal directories.
Click to hide internal directories.