erudito

package module
v0.0.0-...-dffe7f9 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

README

Erudito

CRUD servers made like a symphony.

This software is under development and may be unstable or have significant changes before the final first release.

Trello TO DO Board

https://trello.com/b/7V4yPZlP/erudito

License

GNU GPL V.3

Free Software, OH YEAH !!!

Documentation

Index

Constants

View Source
const (
	MIDDLEWARE_TYPE_GLOBAL     = 1
	MIDDLEWARE_TYPE_COLLECTION = 2
	MIDDLEWARE_TYPE_GET        = 3
	MIDDLEWARE_TYPE_POST       = 4
	MIDDLEWARE_TYPE_PUT        = 5
	MIDDLEWARE_TYPE_PATCH      = 6
	MIDDLEWARE_TYPE_DELETE     = 7
	MIDDLEWARE_TYPE_RELATION   = 8
)

* Type

View Source
const (
	MIDDLEWARE_LEVEL_ANY  = 1
	MIDDLEWARE_LEVEL_ROOT = 2
)

* Level

View Source
const (
	MODEL_TYPE_FULL       = 1
	MODEL_TYPE_HARDDELETE = 2
	MODEL_TYPE_SIMPLE     = 3
)
View Source
const (
	FIELD_TYPE_INTERNAL                    = 1
	FIELD_TYPE_COMMON                      = 2
	FIELD_TYPE_COMMON_TIME                 = 3
	FIELD_TYPE_COMMON_JSON                 = 4
	FIELD_TYPE_RELATION_ID                 = 5
	FIELD_TYPE_RELATION_MODEL              = 6
	FIELD_TYPE_RELATION_COL_IDS            = 7
	FIELD_TYPE_RELATION_COL_IDS_UPDATE     = 8
	FIELD_TYPE_RELATION_COL_IDS_REPLACE    = 9
	FIELD_TYPE_RELATION_COL_MODELS         = 10
	FIELD_TYPE_RELATION_COL_MODELS_UPDATE  = 11
	FIELD_TYPE_RELATION_COL_MODELS_REPLACE = 12
)

Variables

This section is empty.

Functions

func AddCORSHeaders

func AddCORSHeaders(w http.ResponseWriter, methods string)

func CollectionCountHandler

func CollectionCountHandler(model Model, maestro *maestro) http.HandlerFunc

func CollectionHandler

func CollectionHandler(modelZero Model, maestro *maestro) http.HandlerFunc

func CreateMaestro

func CreateMaestro(router *mux.Router, dBPoolCallback DbPoolCallback) *maestro

func DeleteHandler

func DeleteHandler(modelZero Model, maestro *maestro) http.HandlerFunc

func GetHandler

func GetHandler(modelZero Model, maestro *maestro) http.HandlerFunc

func GetNumericRouteField

func GetNumericRouteField(r *http.Request, field string) (uint, error)

func HealthCheckHandler

func HealthCheckHandler(maestro *maestro) http.HandlerFunc

func InternalError

func InternalError(w http.ResponseWriter, err error)

func MakeArrayDataStruct

func MakeArrayDataStruct(dataType reflect.Type, data []interface{}, modelS modelStructure) interface{}

func MakeSingularDataStruct

func MakeSingularDataStruct(dataType reflect.Type, data interface{}, modelS modelStructure) interface{}

func OptionsHandler

func OptionsHandler(headers []string) http.HandlerFunc

func PatchHandler

func PatchHandler(modelZero Model, maestro *maestro) http.HandlerFunc

func PostHandler

func PostHandler(modelZero Model, maestro *maestro) http.HandlerFunc

func PutHandler

func PutHandler(modelZero Model, maestro *maestro) http.HandlerFunc

func RelationAddHandler

func RelationAddHandler(model1, model2 Model, fieldName string, maestro *maestro) http.HandlerFunc

func RelationRemoveHandler

func RelationRemoveHandler(model1, model2 Model, fieldName string, maestro *maestro) http.HandlerFunc

func SendData

func SendData(w http.ResponseWriter, status int, data interface{})

func SendEmptyResponse

func SendEmptyResponse(w http.ResponseWriter, status int)

func SendError

func SendError(w http.ResponseWriter, status int, errs []JSendErrorDescription)

func SendFail

func SendFail(w http.ResponseWriter, status int, message string)

func SendSingleError

func SendSingleError(w http.ResponseWriter, status int, message string, code string)

Types

type CRUDOptions

type CRUDOptions struct {
	ModelSingular string
	ModelPlural   string
}

* Options

type DbPoolCallback

type DbPoolCallback func(r *http.Request, metaData MiddlewareMetaData) *gorm.DB

type FullModel

type FullModel struct {
	ID        uint       `json:"id" gorm:"primary_key"`
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at" sql:"index"`
}

type HardDeleteModel

type HardDeleteModel struct {
	ID        uint       `json:"id" gorm:"primary_key"`
	CreatedAt *time.Time `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

type JSendError

type JSendError struct {
	Status string                  `json:"status"`
	Data   []JSendErrorDescription `json:"data"`
}

type JSendErrorDescription

type JSendErrorDescription struct {
	Code    string  `json:"code"`
	Message string  `json:"message"`
	Refer   *string `json:"refer,omitempty"`
	Pos     *uint   `json:"pos,omitempty"`
}

type JSendFail

type JSendFail struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

type JSendSuccess

type JSendSuccess struct {
	Status string      `json:"status"`
	Data   interface{} `json:"data"`
}

type MiddlewareAfter

type MiddlewareAfter struct {
	Function MiddlewareAfterFunction
	Type     int
	Level    int
}

func MiddlewareAfterCreate

func MiddlewareAfterCreate(function MiddlewareAfterFunction, Type int, Level int) MiddlewareAfter

type MiddlewareAfterData

type MiddlewareAfterData struct {
	R        *http.Request
	W        http.ResponseWriter
	DbConn   *gorm.DB
	Meta     MiddlewareMetaData
	Response map[string]interface{}
}

type MiddlewareAfterFunction

type MiddlewareAfterFunction func(data MiddlewareAfterData) MiddlewareAfterReturn

type MiddlewareAfterReturn

type MiddlewareAfterReturn struct {
	R        *http.Request
	W        http.ResponseWriter
	Meta     MiddlewareMetaData
	Response map[string]interface{}
	Error    *[]JSendErrorDescription
}

type MiddlewareBefore

type MiddlewareBefore struct {
	Function MiddlewareBeforeFunction
	Type     int
	Level    int
}

func MiddlewareBeforeCreate

func MiddlewareBeforeCreate(function MiddlewareBeforeFunction, Type int, Level int) MiddlewareBefore

type MiddlewareBeforeData

type MiddlewareBeforeData struct {
	R      *http.Request
	W      http.ResponseWriter
	DbConn *gorm.DB
	Meta   MiddlewareMetaData
	Model  reflect.Value
}

type MiddlewareBeforeFunction

type MiddlewareBeforeFunction func(data MiddlewareBeforeData) MiddlewareBeforeReturn

type MiddlewareBeforeReturn

type MiddlewareBeforeReturn struct {
	R     *http.Request
	W     http.ResponseWriter
	Meta  MiddlewareMetaData
	Model reflect.Value
	Error *[]JSendErrorDescription
}

type MiddlewareInitial

type MiddlewareInitial struct {
	Function MiddlewareInitialFunction
	Type     int
}

func MiddlewareInitialCreate

func MiddlewareInitialCreate(function MiddlewareInitialFunction, Type int, Level int) MiddlewareInitial

type MiddlewareInitialData

type MiddlewareInitialData struct {
	R    *http.Request
	W    http.ResponseWriter
	Meta MiddlewareMetaData
}

type MiddlewareInitialFunction

type MiddlewareInitialFunction func(data MiddlewareInitialData) MiddlewareInitialReturn

type MiddlewareInitialReturn

type MiddlewareInitialReturn struct {
	R     *http.Request
	W     http.ResponseWriter
	Meta  MiddlewareMetaData
	Error *[]JSendErrorDescription
}

type MiddlewareMetaData

type MiddlewareMetaData map[string]interface{}

type Model

type Model interface {
	CRUDOptions() CRUDOptions
	MiddlewareBefore() []MiddlewareBefore
	MiddlewareAfter() []MiddlewareAfter
}

type RouteConfig

type RouteConfig struct {
	AcceptGET        bool
	AcceptPOST       bool
	AcceptPUT        bool
	AcceptPATCH      bool
	AcceptDELETE     bool
	AcceptCollection bool
}

type SimpleModel

type SimpleModel struct {
	ID uint `json:"id" gorm:"primary_key"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳