restfull

package
v0.0.0-...-86833b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewController

func NewController[Type Resource](name string, opts ...Option[Type]) app.Controller

Types

type Controller

type Controller[Type Resource] struct {
	Controller Type
	*request.Context
	// contains filtered or unexported fields
}

func (*Controller[Type]) BasePath

func (resource *Controller[Type]) BasePath() string

func (*Controller[Type]) CreateOne

func (resource *Controller[Type]) CreateOne()

func (*Controller[Type]) DeleteOne

func (resource *Controller[Type]) DeleteOne()

func (*Controller[Type]) FindAll

func (resource *Controller[Type]) FindAll()

func (*Controller[Type]) FindOne

func (resource *Controller[Type]) FindOne()

func (*Controller[Type]) Mx

func (resource *Controller[Type]) Mx(mapper *app.Mapper)

func (*Controller[Type]) ReplaceOne

func (resource *Controller[Type]) ReplaceOne()

func (*Controller[Type]) UpdateOne

func (resource *Controller[Type]) UpdateOne()

type Option

type Option[Type Resource] func(resource *Controller[Type])

func WithCreateOneFilters

func WithCreateOneFilters[Type Resource](filters ...request.Handler) Option[Type]

func WithDeleteOneFilters

func WithDeleteOneFilters[Type Resource](filters ...request.Handler) Option[Type]

func WithFindAllFilters

func WithFindAllFilters[Type Resource](filters ...request.Handler) Option[Type]

func WithFindOneFilters

func WithFindOneFilters[Type Resource](filters ...request.Handler) Option[Type]

func WithPerPageLimit

func WithPerPageLimit[Type Resource](perPage int) Option[Type]

func WithReplaceOneFilters

func WithReplaceOneFilters[Type Resource](filters ...request.Handler) Option[Type]

func WithUpdateOneFilters

func WithUpdateOneFilters[Type Resource](filters ...request.Handler) Option[Type]

type Resource

type Resource interface {
	FindAllModel() any
	FindOneModel() any
	FindUpdateModel() any

	Model() any
	UpdateOneModel() any

	FindAll(pageData SearchContext) (any, int, validation.Result, error)
	FindOne(resourceId string) (any, validation.Result, error)

	CreateOne() (validation.Result, error)
	UpdateOne(resourceId string) (validation.Result, error)
	DeleteOne(resourceId string) (validation.Result, error)
	ReplaceOne(resourceId string) (validation.Result, error)
}

type SearchContext

type SearchContext struct {
	Page    int
	PerPage int
	SortBy  []SortField `json:"sortBy"`
}

type SortField

type SortField struct {
	Field string `json:"field"`
	Order string `json:"order"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL