goft

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VarPattern       = `[0-9a-zA-Z_\.\(\)]+`
	CompareSign      = ">|>=|<=|<|==|!="
	CompareSignToken = "gt|ge|le|lt|eq|ne"
	ComparePattern   = `^(` + VarPattern + `)\s*(` + CompareSign + `)\s*(` + VarPattern + `)\s*$`
)
View Source
const (
	HTTP_STATUS = "GOFT_STATUS"
)

Variables

View Source
var AnnotationList []Annotation
View Source
var Empty = &struct{}{}

Functions

func Convert

func Convert(handler interface{}) gin.HandlerFunc

func DBMap

func DBMap(columns []string, rows *sql.Rows) ([]interface{}, error)

func Error

func Error(err error, msg ...string)

func ErrorHandler

func ErrorHandler() gin.HandlerFunc

func ExecExpr

func ExecExpr(expr Expr, data map[string]interface{}) (string, error)

执行表达式,临时方法后期需要修改

func GenTplFunc

func GenTplFunc(path string)

根据 函数生成 funcMap ast 语法树

func GetConfigValue

func GetConfigValue(m UserConfig, prefix []string, index int) interface{}

递归读取用户配置文件

func HandleFairing

func HandleFairing(responder Responder, ctx *gin.Context) interface{}

Deprecated ,please call FairingHandler.handlerFairing

func IsAnnotation

func IsAnnotation(t reflect.Type) bool

判断当前的 注入对象 是否是注解

func IsComparableExpr

func IsComparableExpr(expr string) bool

是否是"比较表达式"

func IsNumeric

func IsNumeric(val interface{}) bool

判断是否数字

func LoadConfigFile

func LoadConfigFile() []byte

读取配置文件

func Task

func Task(f TaskFunc, cb func(), params ...interface{})

func Throw

func Throw(err string, code int, context *gin.Context)

Types

type Annotation

type Annotation interface {
	SetTag(tag reflect.StructTag)
	String() string
}

注解处理

type Bean

type Bean interface {
	Name() string
}

type ComparableExpr

type ComparableExpr string

可比较表达式 解析类, 譬如a>3 b!=4 a!=n a>3 [gt .a 3]

type Expr

type Expr string //表达式类型

type Fairing

type Fairing interface {
	OnRequest(*gin.Context) error
	OnResponse(result interface{}) (interface{}, error)
}

type FairingHandler

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

func NewFairingHandler

func NewFairingHandler() *FairingHandler

func (*FairingHandler) AddFairing

func (this *FairingHandler) AddFairing(f ...Fairing)

type GPA

type GPA interface {
	DB() *sql.DB
}

type GPAUtil

type GPAUtil struct {
	GDB GPA `inject:"-"`
}

func NewGPAUtil

func NewGPAUtil() *GPAUtil

type Goft

type Goft struct {
	*gin.Engine
	// contains filtered or unexported fields
}

func Ignite

func Ignite(ginMiddlewares ...gin.HandlerFunc) *Goft

func (*Goft) Attach

func (this *Goft) Attach(f ...Fairing) *Goft

注册中间件

func (*Goft) Beans

func (this *Goft) Beans(beans ...Bean) *Goft

func (*Goft) Config

func (this *Goft) Config(cfgs ...interface{}) *Goft

func (*Goft) Handle

func (this *Goft) Handle(httpMethod, relativePath string, handler interface{}) *Goft

func (*Goft) HandleWithFairing

func (this *Goft) HandleWithFairing(httpMethod, relativePath string, handler interface{}, fairings ...Fairing) *Goft

func (*Goft) Launch

func (this *Goft) Launch()

func (*Goft) LaunchWithPort

func (this *Goft) LaunchWithPort(port int)

func (*Goft) Mount

func (this *Goft) Mount(group string, classes ...IClass) *Goft

func (*Goft) Task

func (this *Goft) Task(cron string, expr interface{}) *Goft

0/3 * * * * * //增加定时任务

type GoftTree

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

func NewGoftTree

func NewGoftTree() *GoftTree

type GormAdapter

type GormAdapter struct {
	*gorm.DB
}

func NewGormAdapter

func NewGormAdapter() *GormAdapter

func (*GormAdapter) Name

func (this *GormAdapter) Name() string

type IClass

type IClass interface {
	Build(goft *Goft) //参数和方法名必须一致
	Name() string
}

type Json

type Json interface{}

type JsonResponder

type JsonResponder func(*gin.Context) Json

func (JsonResponder) RespondTo

func (this JsonResponder) RespondTo() gin.HandlerFunc

type Model

type Model interface {
	String() string
}

type Models

type Models string

func MakeModels

func MakeModels(v interface{}) Models

type Param

type Param struct {
	Key   string
	Value string
}

Param is a single URL parameter, consisting of a key and a value.

type Params

type Params []Param

Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.

func (Params) ByName

func (ps Params) ByName(name string) (va string)

ByName returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.

func (Params) Get

func (ps Params) Get(name string) (string, bool)

Get returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.

type Query

type Query interface {
	Sql() string
	Args() []interface{}
	Mapping() map[string]string
	First() bool
	Key() string
	Get() interface{}
}

type Responder

type Responder interface {
	RespondTo() gin.HandlerFunc
}

type RouteInfo

type RouteInfo struct {
	Method      string
	Path        string
	Handler     string
	HandlerFunc interface{}
}

type RoutesInfo

type RoutesInfo []RouteInfo

type ServerConfig

type ServerConfig struct {
	Port int32
	Name string
	Html string
}

type SimpleExpr

type SimpleExpr string

普通表达式,如 .user.Age .user.Info(101)

type SimpleQuery

type SimpleQuery string

func (SimpleQuery) Args

func (this SimpleQuery) Args() []interface{}

func (SimpleQuery) First

func (this SimpleQuery) First() bool

func (SimpleQuery) Get

func (this SimpleQuery) Get() interface{}

func (SimpleQuery) Key

func (this SimpleQuery) Key() string

func (SimpleQuery) Mapping

func (this SimpleQuery) Mapping() map[string]string

func (SimpleQuery) Sql

func (this SimpleQuery) Sql() string

func (SimpleQuery) WithArgs

func (this SimpleQuery) WithArgs(args ...interface{}) *SimpleQueryWithArgs

func (SimpleQuery) WithFirst

func (this SimpleQuery) WithFirst() *SimpleQueryWithArgs

func (SimpleQuery) WithKey

func (this SimpleQuery) WithKey(key string) *SimpleQueryWithArgs

func (SimpleQuery) WithMapping

func (this SimpleQuery) WithMapping(mapping map[string]string) *SimpleQueryWithArgs

type SimpleQueryWithArgs

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

func NewSimpleQueryWithArgs

func NewSimpleQueryWithArgs(sql string, args []interface{}) *SimpleQueryWithArgs

func NewSimpleQueryWithFetchFirst

func NewSimpleQueryWithFetchFirst(sql string) *SimpleQueryWithArgs

func NewSimpleQueryWithKey

func NewSimpleQueryWithKey(sql string, key string) *SimpleQueryWithArgs

func NewSimpleQueryWithMapping

func NewSimpleQueryWithMapping(sql string, mapping map[string]string) *SimpleQueryWithArgs

func (*SimpleQueryWithArgs) Args

func (this *SimpleQueryWithArgs) Args() []interface{}

func (*SimpleQueryWithArgs) First

func (this *SimpleQueryWithArgs) First() bool

func (*SimpleQueryWithArgs) Get

func (this *SimpleQueryWithArgs) Get() interface{}

func (*SimpleQueryWithArgs) Key

func (this *SimpleQueryWithArgs) Key() string

func (*SimpleQueryWithArgs) Mapping

func (this *SimpleQueryWithArgs) Mapping() map[string]string

func (*SimpleQueryWithArgs) Sql

func (this *SimpleQueryWithArgs) Sql() string

func (*SimpleQueryWithArgs) WithFirst

func (this *SimpleQueryWithArgs) WithFirst() *SimpleQueryWithArgs

func (*SimpleQueryWithArgs) WithKey

func (this *SimpleQueryWithArgs) WithKey(key string) *SimpleQueryWithArgs

func (*SimpleQueryWithArgs) WithMapping

func (this *SimpleQueryWithArgs) WithMapping(mapping map[string]string) *SimpleQueryWithArgs

type SqlQueryResponder

type SqlQueryResponder func(*gin.Context) Query

func (SqlQueryResponder) RespondTo

func (this SqlQueryResponder) RespondTo() gin.HandlerFunc

type SqlResponder

type SqlResponder func(*gin.Context) SimpleQuery

func (SqlResponder) RespondTo

func (this SqlResponder) RespondTo() gin.HandlerFunc

type StringResponder

type StringResponder func(*gin.Context) string

func (StringResponder) RespondTo

func (this StringResponder) RespondTo() gin.HandlerFunc

type SysConfig

type SysConfig struct {
	Server *ServerConfig
	Config UserConfig
}

系统配置

func InitConfig

func InitConfig() *SysConfig

func NewSysConfig

func NewSysConfig() *SysConfig

func (*SysConfig) Name

func (this *SysConfig) Name() string

type TaskExecutor

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

func NewTaskExecutor

func NewTaskExecutor(f TaskFunc, p []interface{}, callback func()) *TaskExecutor

func (*TaskExecutor) Exec

func (this *TaskExecutor) Exec()

type TaskFunc

type TaskFunc func(params ...interface{})

type TreeNode

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

type TreeRouter

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

func NewTreeRouter

func NewTreeRouter() *TreeRouter

type UserConfig

type UserConfig map[interface{}]interface{}

type Value

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

func (*Value) SetTag

func (this *Value) SetTag(tag reflect.StructTag)

func (*Value) String

func (this *Value) String() string

type View deprecated

type View string

Deprecated: 暂时不提供View的解析

type ViewResponder

type ViewResponder func(*gin.Context) View

func (ViewResponder) RespondTo

func (this ViewResponder) RespondTo() gin.HandlerFunc

type Void

type Void struct{}

type VoidResponder

type VoidResponder func(ctx *gin.Context) Void

func (VoidResponder) RespondTo

func (this VoidResponder) RespondTo() gin.HandlerFunc

Jump to

Keyboard shortcuts

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