catu

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: GPL-3.0 Imports: 35 Imported by: 12

README

Catu

Beware: In development!!!!!!!

Catupiri framework core module

usage

// Start the new app:
app := catu.NewApp()
// Register your plugins
app.RegisterPlugin("mm", mm.GetPlugin())
// Start the bootstrap process, will load all resources, bind routes, middlewares ...
app.Bootstrap()

// here you can use the app resources like run a command or start a server...

// Start the http server if required:
app.StartHTTPServer()

Core events

Powered by: https://github.com/gookit/event

  • configuration
  • bindMiddlewares
  • bindRoutes
  • setResponseFormats
  • bootstrap

Run tests:

go test ./...

Build with

  • Go
  • Time
  • Unknow things that some call magic

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SanitizerDefault *bluemonday.Policy

Functions

func BindMiddlewares added in v0.0.1

func BindMiddlewares(app *App, p *Plugin)

BindMiddlewares - Bind middlewares in order

func CustomHTTPErrorHandler added in v0.0.1

func CustomHTTPErrorHandler(err error, c echo.Context)

func GetConfiguration added in v0.0.1

func GetConfiguration() configuration.Configer

func GetDefaultDatabaseConnection added in v0.0.1

func GetDefaultDatabaseConnection() *gorm.DB

func GetPathLimitFromReq added in v0.0.1

func GetPathLimitFromReq()

func GetQueryInt64FromReq added in v0.0.1

func GetQueryInt64FromReq(param string, c echo.Context) int64

func GetQueryIntFromReq added in v0.0.1

func GetQueryIntFromReq(param string, c echo.Context) int

func GetSanitizer added in v0.0.1

func GetSanitizer() *bluemonday.Policy

func HealthCheckHandler added in v0.0.1

func HealthCheckHandler(c echo.Context) error

func InitSanitizer added in v0.0.1

func InitSanitizer()

func SendManyJSONApi added in v0.0.1

func SendManyJSONApi(c echo.Context, count int64, pointerArr interface{}) error

func SendOneJSONApi added in v0.0.1

func SendOneJSONApi(c echo.Context, record interface{}) error

Types

type App

type App struct {
	InitTime time.Time

	Events *event.Manager

	Configuration configuration.Configer
	// Default database
	DB *gorm.DB
	// avaible databases
	DBs map[string]*gorm.DB

	Plugins map[string]Pluginer

	Models map[string]interface{}

	RolesString string
	RolesList   map[string]acl.Role
	// contains filtered or unexported fields
}

func GetApp added in v0.0.1

func GetApp() *App

func Init

func Init() *App

func (*App) Bootstrap added in v0.0.1

func (r *App) Bootstrap() error

func (*App) Can added in v0.0.1

func (r *App) Can(permission string, userRoles []string) bool

func (*App) GetAPIRouterGroup added in v0.0.1

func (r *App) GetAPIRouterGroup(name string) *echo.Group

func (*App) GetModel added in v0.0.1

func (r *App) GetModel(name string) interface{}

func (*App) GetRouter added in v0.0.1

func (r *App) GetRouter() *echo.Echo

func (*App) GetRouterGroup added in v0.0.1

func (r *App) GetRouterGroup(name string) *echo.Group

func (*App) GetTemplates added in v0.0.1

func (r *App) GetTemplates() *template.Template

func (*App) InitDatabase added in v0.0.1

func (r *App) InitDatabase(name, engine string, isDefault bool) error

func (*App) LoadTemplates added in v0.0.1

func (r *App) LoadTemplates() error

func (*App) RegisterPlugin added in v0.0.1

func (r *App) RegisterPlugin(p Pluginer)

func (*App) SetAPIRouterGroup added in v0.0.1

func (r *App) SetAPIRouterGroup(name, path string) *echo.Group

func (*App) SetModel added in v0.0.1

func (r *App) SetModel(name string, f interface{})

func (*App) SetRouterGroup added in v0.0.1

func (r *App) SetRouterGroup(name, path string) *echo.Group

func (*App) SetTemplateFunction added in v0.0.1

func (r *App) SetTemplateFunction(name string, f interface{})

func (*App) StartHTTPServer added in v0.0.1

func (r *App) StartHTTPServer() error

type AppContext added in v0.0.1

type AppContext struct {
	PathBeforeAlias string
	Protocol        string
	Hostname        string
	AppOrigin       string
	Title           string

	IsAuthenticated   bool
	AuthenticatedUser UserInterface
	// authenticated user role name list
	Roles []string

	Session SessionData

	// Widgets     map[string]map[string]string
	Layout              string
	BodyClass           []string
	Content             template.HTML
	ContentData         map[string]interface{}
	Query               Query
	Pager               *pagination.Pager
	MetaTags            HTMLMetaTags
	ResponseContentType string

	ENV string
}

func NewAppContext added in v0.0.1

func NewAppContext() AppContext

func NewRequestAppContext added in v0.0.1

func NewRequestAppContext(c echo.Context) AppContext

func (*AppContext) AddBodyClass added in v0.0.1

func (r *AppContext) AddBodyClass(class string)

Add a body class string checking if is unique

func (*AppContext) Can added in v0.0.1

func (r *AppContext) Can(permission string) bool

func (*AppContext) Get added in v0.0.1

func (r *AppContext) Get(name string) interface{}

func (*AppContext) GetAuthenticatedRoles added in v0.0.1

func (r *AppContext) GetAuthenticatedRoles() *[]string

func (*AppContext) GetBodyClassText added in v0.0.1

func (r *AppContext) GetBodyClassText() string

Get body class as string,

func (*AppContext) GetBool added in v0.0.1

func (r *AppContext) GetBool(name string) bool

func (*AppContext) GetLimit added in v0.0.1

func (r *AppContext) GetLimit() int

func (*AppContext) GetOffset added in v0.0.1

func (r *AppContext) GetOffset() int

func (*AppContext) GetString added in v0.0.1

func (r *AppContext) GetString(name string) string

func (*AppContext) GetStringMap added in v0.0.1

func (r *AppContext) GetStringMap(name string) []string

func (*AppContext) GetTemplateHTML added in v0.0.1

func (r *AppContext) GetTemplateHTML(name string) template.HTML

func (*AppContext) ParseQueryFromReq added in v0.0.1

func (r *AppContext) ParseQueryFromReq(c echo.Context) error

func (*AppContext) RemoveBodyClass added in v0.0.1

func (r *AppContext) RemoveBodyClass(class string)

Remove a body class string checking if is unique

func (*AppContext) Render added in v0.0.1

func (r *AppContext) Render(wr io.Writer, name string, data interface{}) error

Render one template, alias to app.templates.ExecuteTemplate()

func (*AppContext) RenderMetaTags added in v0.0.1

func (r *AppContext) RenderMetaTags() template.HTML

func (*AppContext) RenderPagination added in v0.0.1

func (r *AppContext) RenderPagination(name string) string

func (*AppContext) Set added in v0.0.1

func (r *AppContext) Set(name string, value interface{})

func (*AppContext) SetAuthenticatedUser added in v0.0.1

func (r *AppContext) SetAuthenticatedUser(user UserInterface)

func (*AppContext) SetAuthenticatedUserAndFillRoles added in v0.0.1

func (r *AppContext) SetAuthenticatedUserAndFillRoles(user UserInterface)

type BaseErrorResponse added in v0.0.1

type BaseErrorResponse struct {
	Messages []BaseErrorResponseMessage `json:"messages"`
}

type BaseErrorResponseMessage added in v0.0.1

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

type BaseListReponse added in v0.0.1

type BaseListReponse struct {
	Meta BaseMetaResponse `json:"meta"`
}

type BaseMetaResponse added in v0.0.1

type BaseMetaResponse struct {
	Count int64 `json:"count"`
}

type ContentDates added in v0.0.1

type ContentDates interface {
	GetTeaserDatesHTML(separator string) template.HTML
}

type HTMLMetaTags

type HTMLMetaTags struct {
	Title       string
	Description string
	Canonical   string
	SiteName    string
	Type        string
	ImageURL    string
	Keywords    string

	TwitterSite string
}

type Plugin added in v0.0.1

type Plugin struct {
	Name string
}

func (*Plugin) BindMiddlewares added in v0.0.1

func (p *Plugin) BindMiddlewares(a *App) error

func (*Plugin) GetName added in v0.0.1

func (p *Plugin) GetName() string

func (*Plugin) Init added in v0.0.1

func (p *Plugin) Init(a *App) error

func (*Plugin) SetTemplateFuncMap added in v0.0.1

func (p *Plugin) SetTemplateFuncMap(app *App) error

type PluginManager added in v0.0.1

type PluginManager interface {
	GetRouter(name string) *echo.Group
	SetRouter(name string) *echo.Group
	GetAPIRouter(name string) *echo.Group
}

type Pluginer added in v0.0.1

type Pluginer interface {
	Init(app *App) error
	GetName() string

	SetTemplateFuncMap(app *App) error
}

type Query

type Query struct {
	Fields      []QueryAttr
	QueryString string
}

func (*Query) AddQueryParamFromRaw

func (r *Query) AddQueryParamFromRaw(paramName string, values []string) error

func (*Query) AddQueryString

func (r *Query) AddQueryString(paramName string, values []string)

func (*Query) GetParamValue

func (r *Query) GetParamValue(paramName string) string

func (*Query) GetQueryString

func (r *Query) GetQueryString(paramName string) string

type QueryAttr

type QueryAttr struct {
	Operator   string
	Values     []string
	IsMultiple bool
	ParamName  string
}

type SessionData added in v0.0.1

type SessionData struct {
	UserID int64
}

type TemplateCTX added in v0.0.1

type TemplateCTX struct {
	Ctx     interface{}
	Record  interface{}
	Records interface{}
}

type TemplateRenderer added in v0.0.1

type TemplateRenderer struct {
	// contains filtered or unexported fields
}

func (*TemplateRenderer) Render added in v0.0.1

func (t *TemplateRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error

type UserInterface added in v0.0.1

type UserInterface interface {
	GetRoles() []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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