rest

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	POSTGRES_NOT_NULL_VIOLATION          = "23502"
	POSTGRES_ERROR_FOREIGN_KEY_VIOLATION = "23503"
	POSTGRES_ERROR_UNIQUE_VIOLATION      = "23505"
	POSTGRES_CHECK_VIOLATION             = "23514"
	POSTGRES_INVALID_TEXT_REPRESENTATION = "22P02"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterDeleteLifecycleHook

type AfterDeleteLifecycleHook func(response *response.Response, request *http.Request) error

type AfterIndexLifecycleHook

type AfterIndexLifecycleHook func(response *response.Response, request *http.Request, model *[]surf.Model) error

type BaseController

type BaseController struct {
	GetModel        surf.BuildModel
	LifecycleHooks  LifecycleHooks
	MethodWhiteList []string
}

func (BaseController) Create

func (c BaseController) Create(w http.ResponseWriter, r *http.Request)

func (BaseController) Delete

func (c BaseController) Delete(w http.ResponseWriter, r *http.Request)

func (BaseController) Index

func (BaseController) Register

func (c BaseController) Register(r *httprouter.Router, mw turf.Middleware)

func (BaseController) Show

func (BaseController) Update

func (c BaseController) Update(w http.ResponseWriter, r *http.Request)

type BaseLifecycleHook

type BaseLifecycleHook func(response *response.Response, request *http.Request, model surf.Model) error

type BeforeIndexLifecycleHook

type BeforeIndexLifecycleHook func(response *response.Response, request *http.Request, model *surf.BulkFetchConfig) error

type LifecycleHooks

type LifecycleHooks struct {
	// After validation and model prep, but before creation
	BeforeCreate BaseLifecycleHook

	// After create, but before HTTP response
	AfterCreate BaseLifecycleHook

	// After the BulkFetchConfig is set, but before the fetch
	BeforeIndex BeforeIndexLifecycleHook

	// After the fetch, but before the response
	AfterIndex AfterIndexLifecycleHook

	// After the model is prepared to be loaded, but before it is actually loaded
	BeforeShow BaseLifecycleHook

	// After the model is loaded, but before the HTTP response
	AfterShow BaseLifecycleHook

	// After the model has been loaded + the values have been validated + set to the model,
	// but before the model is updated
	BeforeUpdate BaseLifecycleHook

	// After update, but before HTTP response
	AfterUpdate BaseLifecycleHook

	// After the models identifier has been set, but before the deletion
	BeforeDelete BaseLifecycleHook

	// After the model has been deleted, but before the HTTP response
	AfterDelete AfterDeleteLifecycleHook
}

type ManyToManyController

type ManyToManyController struct {
	GetBaseModel                surf.BuildModel
	GetNestedModel              surf.BuildModel
	GetRelationModel            surf.BuildModel
	BaseModelForeignReference   string
	NestedModelForeignReference string
	LifecycleHooks              LifecycleHooks
	MethodWhiteList             []string
}

func (ManyToManyController) Create

func (ManyToManyController) Delete

func (ManyToManyController) Index

func (ManyToManyController) Register

func (ManyToManyController) Show

func (ManyToManyController) Update

type OneToManyController

type OneToManyController struct {
	GetBaseModel           surf.BuildModel
	GetNestedModel         surf.BuildModel
	NestedForeignReference string
	BelongsTo              func(baseModel, nestedModel surf.Model) bool
	LifecycleHooks         LifecycleHooks
	MethodWhiteList        []string
}

func (OneToManyController) Create

func (OneToManyController) Delete

func (OneToManyController) Index

func (OneToManyController) Register

func (OneToManyController) Show

func (OneToManyController) Update

type OneToOneController

type OneToOneController struct {
	NestedModelNameSingular string
	ForeignReference        string
	GetBaseModel            surf.BuildModel
	GetNestedModel          surf.BuildModel
	LifecycleHooks          LifecycleHooks
	MethodWhiteList         []string
}

func (OneToOneController) Create

func (OneToOneController) Delete

func (OneToOneController) Index

func (OneToOneController) Register

func (c OneToOneController) Register(r *httprouter.Router, mw turf.Middleware)

func (OneToOneController) Show

func (OneToOneController) Update

Jump to

Keyboard shortcuts

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