camBase

package
v0.5.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfigInterface

type AppConfigInterface interface {
}

app config interface

type ApplicationInterface

type ApplicationInterface interface {
	// get Component instance by reflect
	GetComponent(v ComponentInterface) ComponentInterface
	// get Component instance by component name
	GetComponentByName(name string) ComponentInterface
	// get default db component's interface
	GetDB() DatabaseComponentInterface
	// run application
	Run()
	// stop application
	Stop()
	// add migration struct
	AddMigration(m MigrationInterface)
	// log trace
	Trace(title string, content string)
	// log debug
	Debug(title string, content string)
	// log info
	Info(title string, content string)
	// log warn
	Warn(title string, content string)
	// log error
	Error(title string, content string)
	// log fatal
	Fatal(title string, content string)
	// Add config
	AddConfig(config AppConfigInterface)
	// get value form .evn file
	GetEvn(key string) string
	// get params form camAppConfig.Config.Params
	GetParam(key string) interface{}
	// get migrate dict
	GetMigrateDict() map[string]MigrationInterface
	// get cache component
	GetCache() CacheComponentInterface
	// get mail component
	GetMail() MailComponentInterface
	// valid struct.
	Valid(v interface{}) (firstErr error, errDict map[string][]error)
}

application interface NODE: Provides interface function to the module inner framework

type ApplicationStatus

type ApplicationStatus int

app status

type CacheComponentInterface

type CacheComponentInterface interface {
	// set cache storage default duration
	Set(key string, value interface{}) error
	// set cache storage custom duration
	SetDuration(key string, value interface{}, duration time.Duration) error
	// whether the key exists
	Exists(key string) bool
	// get value by key
	Get(key string) interface{}
	// delete cache
	Del(keys ...string) error
	// delete all cache
	Flush() error
}

cache component interface

type CamModuleType

type CamModuleType int

CamModule type

type ComponentConfigInterface

type ComponentConfigInterface interface {
	// new component
	NewComponent() ComponentInterface
	// get recover handler
	GetRecoverHandler() RecoverHandler
}

component config interface

type ComponentInterface

type ComponentInterface interface {
	// init
	Init(configInterface ComponentConfigInterface)
	// start
	Start()
	// stop
	Stop()
	// set app instance
	SetApp(app ApplicationInterface)
}

Component interface

type ConsoleComponentInterface

type ConsoleComponentInterface interface {
	// get database dir
	GetDatabaseDir() string
	// get xorm template dir
	GetXormTemplateDir() string
}

console component interface

type ContextHttpInterface added in v0.4.0

type ContextHttpInterface interface {
	ContextInterface
	SetHttpResponseWriter(responseWriter http.ResponseWriter)
	GetHttpResponseWriter() http.ResponseWriter
	SetHttpRequest(request *http.Request)
	GetHttpRequest() *http.Request
}

http context it will inject http.ResponseWriter and request *http.Request to context Deprecated: remove on v0.5.0 Instead: HttpContextInterface

type ContextInterface

type ContextInterface interface {
	// set session
	SetSession(session SessionInterface)
	// get session
	GetSession() SessionInterface
	// Write returned data
	Write(res []byte)
	// Read returned data
	Read() []byte
	// Set RecoverInterface. As a error panic by last handle route of handler
	SetRecover(rec RecoverInterface)
	// Get RecoverInterface
	GetRecover() RecoverInterface
}

context interface

type ControllerActionInterface

type ControllerActionInterface interface {
	// controller route
	Route() string
	// call action
	Call()
}

controller action interface

type ControllerInterface

type ControllerInterface interface {
	// init
	Init()
	// before action
	BeforeAction(action ControllerActionInterface) bool
	// after action
	AfterAction(action ControllerActionInterface, response []byte) []byte
	// set context
	SetContext(context ContextInterface)
	// get context
	GetContext() ContextInterface
	// set session
	// Deprecated: remove on v0.5.0
	// Instead: GetContext().SetSession();
	SetSession(session SessionInterface)
	// get session
	// Deprecated: remove on v0.5.0
	// Instead: GetContext().GetSession();
	GetSession() SessionInterface
	// set values.
	// it will replace the original values
	SetValues(values map[string]interface{})
	// get default action
	GetDefaultActionName() string
	// set response
	// Deprecated: remove on v0.5.0
	// Instead: GetContext().Write();
	SetResponse([]byte)
	// get response
	// Deprecated: remove on v0.5.0
	// Instead: GetContext().Read();
	GetResponse() []byte
	// set recover
	// Deprecated: remove on v0.5.0
	// Instead: GetContext().SetRecover();
	SetRecover(rec RecoverInterface)
	// get recover
	// Deprecated: remove on v0.5.0
	// Instead: GetContext().GetRecover();
	GetRecover() RecoverInterface
}

controller interface

type DatabaseComponentInterface

type DatabaseComponentInterface interface {
	// get data source name.
	// [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
	GetDSN() string
	// get engine
	GetEngine() *xorm.Engine
	// get xorm session
	NewSession() *xorm.Session
}

database component interface

type HttpContextInterface added in v0.4.1

type HttpContextInterface interface {
	ContextInterface
	SetHttpResponseWriter(responseWriter http.ResponseWriter)
	GetHttpResponseWriter() http.ResponseWriter
	SetHttpRequest(request *http.Request)
	GetHttpRequest() *http.Request
	CloseHandler(handler func())
	Close()
}

http context

type HttpRouteHandler

type HttpRouteHandler func(responseWriter http.ResponseWriter, request *http.Request)

http custom route handler

type LogLevel

type LogLevel uint8

log level

type MailComponentInterface

type MailComponentInterface interface {
	Send(subject string, body string, to ...string) error
}

mail component interface

type MessageParseHandler added in v0.4.0

type MessageParseHandler func(message []byte) (controllerName string, actionName string, values map[string]interface{})

message parse handler. it can read route and values info form the message

type MiddlewareInterface added in v0.4.1

type MiddlewareInterface interface {
	// call when route has middleware
	Handler(ctx ContextInterface, next NextHandler) []byte
}

middleware interface

type MigrationInterface

type MigrationInterface interface {
	// update migration
	Up()
	// recall migration
	Down()
	// get up sql list
	GetSqlList() []string
}

migration interface

type NextHandler added in v0.4.1

type NextHandler func() []byte

the next Handler. The processing method of Middleware

type PluginConfigInterface

type PluginConfigInterface interface {
	Init()
}

type PluginInterface

type PluginInterface interface {
	Init(configInterface PluginConfigInterface)
}

type RecoverHandler

type RecoverHandler func(rec interface{}) RecoverHandlerResult

component recover handler

type RecoverHandlerResult

type RecoverHandlerResult uint8

recover handler result

type RecoverInterface

type RecoverInterface interface {
	Error() string
	GetError() error
}

recoverable interface

type RouteHandler added in v0.4.1

type RouteHandler func(ctxI ContextInterface) []byte

route Handler Such as: Custom Handler, ControllerAction Handler

type RuleInterface added in v0.4.0

type RuleInterface interface {
	// get fields of validation
	Fields() []string
	// get handlers of validation
	Handlers() []ValidHandler
}

rule

type SessionInterface

type SessionInterface interface {
	// get sessionId
	GetSessionId() string
	// set key-value in session
	Set(key interface{}, value interface{})
	// get value by key
	Get(key interface{}) interface{}
	// delete value by key
	Del(key interface{})
	// destroy session
	Destroy()
}

session interface

type SocketConnHandler added in v0.4.0

type SocketConnHandler func(conn net.Conn)

socket conn handler

type SocketRouteHandler added in v0.4.0

type SocketRouteHandler func(conn net.Conn) []byte

socket custom route handler

type ValidHandler added in v0.4.0

type ValidHandler func(value reflect.Value) error

valid handler

type ValidInterface added in v0.4.0

type ValidInterface interface {
	// get rules
	Rules() []RuleInterface
}

valid interface

type ValidMode added in v0.4.0

type ValidMode uint8

valid mode priority level

type ValidationComponentInterface added in v0.4.0

type ValidationComponentInterface interface {
	// valid struct
	Valid(v interface{}) map[string][]error
}

validation component interface

type WebsocketRouteHandler

type WebsocketRouteHandler func(conn *websocket.Conn) []byte

websocket custom route handler

Jump to

Keyboard shortcuts

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