goft

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 28 Imported by: 16

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 added in v0.3.3

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 added in v0.2.2

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 added in v0.2.2

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 added in v0.2.2

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

func NewFairingHandler added in v0.3.0

func NewFairingHandler() *FairingHandler

func (*FairingHandler) AddFairing added in v0.2.2

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

type GPA added in v0.3.3

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

type GPAUtil added in v0.3.3

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

func NewGPAUtil added in v0.3.3

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 added in v0.3.2

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

func (*Goft) Handle

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

func (*Goft) HandleWithFairing added in v0.3.0

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

func (*Goft) Launch

func (this *Goft) Launch()

func (*Goft) LaunchWithPort added in v0.5.3

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 added in v0.3.0

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

func NewGoftTree added in v0.3.0

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 added in v0.2.2

type Json interface{}

type JsonResponder added in v0.2.2

type JsonResponder func(*gin.Context) Json

func (JsonResponder) RespondTo added in v0.2.2

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 added in v0.3.0

type Param struct {
	Key   string
	Value string
}

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

type Params added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

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 added in v0.3.4

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 added in v0.3.0

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

type RoutesInfo added in v0.3.0

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 added in v0.3.3

type SimpleQuery string

func (SimpleQuery) Args added in v0.3.4

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

func (SimpleQuery) First added in v0.3.4

func (this SimpleQuery) First() bool

func (SimpleQuery) Get added in v0.3.6

func (this SimpleQuery) Get() interface{}

func (SimpleQuery) Key added in v0.3.6

func (this SimpleQuery) Key() string

func (SimpleQuery) Mapping added in v0.3.4

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

func (SimpleQuery) Sql added in v0.3.4

func (this SimpleQuery) Sql() string

func (SimpleQuery) WithArgs added in v0.3.4

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

func (SimpleQuery) WithFirst added in v0.3.4

func (this SimpleQuery) WithFirst() *SimpleQueryWithArgs

func (SimpleQuery) WithKey added in v0.3.6

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

func (SimpleQuery) WithMapping added in v0.3.4

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

type SimpleQueryWithArgs added in v0.3.4

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

func NewSimpleQueryWithArgs added in v0.3.4

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

func NewSimpleQueryWithFetchFirst added in v0.3.4

func NewSimpleQueryWithFetchFirst(sql string) *SimpleQueryWithArgs

func NewSimpleQueryWithKey added in v0.3.6

func NewSimpleQueryWithKey(sql string, key string) *SimpleQueryWithArgs

func NewSimpleQueryWithMapping added in v0.3.4

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

func (*SimpleQueryWithArgs) Args added in v0.3.4

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

func (*SimpleQueryWithArgs) First added in v0.3.4

func (this *SimpleQueryWithArgs) First() bool

func (*SimpleQueryWithArgs) Get added in v0.3.6

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

func (*SimpleQueryWithArgs) Key added in v0.3.6

func (this *SimpleQueryWithArgs) Key() string

func (*SimpleQueryWithArgs) Mapping added in v0.3.4

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

func (*SimpleQueryWithArgs) Sql added in v0.3.4

func (this *SimpleQueryWithArgs) Sql() string

func (*SimpleQueryWithArgs) WithFirst added in v0.3.4

func (this *SimpleQueryWithArgs) WithFirst() *SimpleQueryWithArgs

func (*SimpleQueryWithArgs) WithKey added in v0.3.6

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

func (*SimpleQueryWithArgs) WithMapping added in v0.3.4

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

type SqlQueryResponder added in v0.3.4

type SqlQueryResponder func(*gin.Context) Query

func (SqlQueryResponder) RespondTo added in v0.3.4

func (this SqlQueryResponder) RespondTo() gin.HandlerFunc

type SqlResponder added in v0.3.3

type SqlResponder func(*gin.Context) SimpleQuery

func (SqlResponder) RespondTo added in v0.3.3

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 added in v0.3.0

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

type TreeRouter added in v0.3.0

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

func NewTreeRouter added in v0.3.0

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 added in v0.5.0

type Void struct{}

type VoidResponder added in v0.5.0

type VoidResponder func(ctx *gin.Context) Void

func (VoidResponder) RespondTo added in v0.5.0

func (this VoidResponder) RespondTo() gin.HandlerFunc

Jump to

Keyboard shortcuts

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