Documentation ¶
Index ¶
- Constants
- Variables
- func ClearTerm()
- func Data(code int, data []byte) *responseData
- func Debounce(after time.Duration) func(func())
- func Html(code int, data []byte) *responseHtml
- func JWTToken(payload map[string]any, secret []byte) (string, error)
- func Json(code int, data any) *responseJson
- func Loading(done chan int, message string)
- func ParseJWT(token string, secret []byte) (map[string]any, error)
- func SetCors(origin, methods, headers string) func(*Context) IResponse
- func Spinner() func() string
- func StatusCode(code int) *responseStatusCode
- func String(code int, format string, v ...any) *responseString
- type AppConfig
- type Context
- type DataEngine
- type DataSession
- func (session *DataSession) Clear()
- func (session *DataSession) Delete() error
- func (session *DataSession) Equal(name string, value any) *DataSession
- func (session *DataSession) Insert(v ...any) error
- func (session *DataSession) Limit(args ...int) *DataSession
- func (session *DataSession) OrderBy(name string) *DataSession
- func (session *DataSession) Select(v any) error
- func (session *DataSession) Set(name string, value any) *DataSession
- func (session *DataSession) Table(name string) *DataSession
- func (session *DataSession) Update() error
- func (session *DataSession) Where(name string, opt string, value any) *DataSession
- type GLogger
- type GONE_CONFIG_CONTENT
- type GONE_TLS_CERT
- type GONE_TLS_KEY
- type Handler
- type IFileConfig
- type IHandler
- type IResponse
- type RouterGroup
- func (group *RouterGroup) After(afters ...func(ctx *Context) IResponse)
- func (group *RouterGroup) Before(befores ...func(ctx *Context) IResponse)
- func (group *RouterGroup) Get(pattern string, handler func(ctx *Context) IResponse)
- func (group *RouterGroup) Group(prefix string) *RouterGroup
- func (group *RouterGroup) Post(pattern string, handler func(ctx *Context) IResponse)
- type WEvent
- type Watcher
- type WebEngine
Constants ¶
View Source
const ( LogRed int = 31 LogGreen int = 32 LogYellow int = 33 LogBlue int = 36 LogPurple int = 35 )
View Source
const DEFAULT_BUILD_NAME = "main"
DEFAULT_BUILD_NAME 编译后的文件名
View Source
const DEFAULT_CONFIG_PATH string = "application.json"
DEFAULT_CONFIG_PATH 默认配置文件地址
View Source
const DEFAULT_INOTIFY_MASK uint32 = syscall.IN_MODIFY | syscall.IN_CREATE | syscall.IN_DELETE_SELF
DEFAULT_INOTIFY_MASK 默认监听事件
IN_MODIFY 文件被修改
IN_CREATE 目录被创建
IN_DELETE_SELF 目录被删除 TODO: 文件移动事件也应该触发热更新
Variables ¶
View Source
var ( LogInfo = infoLogger.Println LogInfof = infoLogger.Printf LogWarn = warnLogger.Println LogWarnf = warnLogger.Printf LogErr = errLogger.Println LogErrf = errLogger.Printf )
Functions ¶
Types ¶
type AppConfig ¶
type AppConfig struct { Name string `json:"name"` Port int `json:"port"` Production bool `json:"production"` MainFile string `json:"mainFile"` Loggers []struct { Name string `json:"name"` Output bool `json:"output"` } `json:"loggers"` Watcher struct { Includes []string `json:"includes"` Excludes []string `json:"excludes"` } `json:"watcher"` Database struct { Host string `json:"host"` Port int `json:"port"` Username string `json:"username"` Password string `json:"password"` DdName string `json:"dbName"` Max int `json:"max"` } `json:"database"` }
AppConfig 项目配置
func (*AppConfig) ParseContent ¶
ParseContent 从二进制加载配置
type Context ¶
type Context struct { Source *DataSession Req *http.Request Resp http.ResponseWriter Method string Path string // contains filtered or unexported fields }
Context 上下文
type DataEngine ¶
type DataEngine struct {
// contains filtered or unexported fields
}
DataEngine 数据库引擎
func (*DataEngine) NewSession ¶
func (engine *DataEngine) NewSession() *DataSession
NewSession 获取数据库会话
type DataSession ¶
DataSession 数据库会话
func (*DataSession) Equal ¶
func (session *DataSession) Equal(name string, value any) *DataSession
Equal 字段等于
func (*DataSession) OrderBy ¶
func (session *DataSession) OrderBy(name string) *DataSession
OrderBy 排序语句
func (*DataSession) Set ¶
func (session *DataSession) Set(name string, value any) *DataSession
Set 设置修改参数
func (*DataSession) Table ¶
func (session *DataSession) Table(name string) *DataSession
Table 设置表格名称
func (*DataSession) Where ¶
func (session *DataSession) Where(name string, opt string, value any) *DataSession
Where 设置 where 子句
type GLogger ¶
type GLogger struct {
// contains filtered or unexported fields
}
GLogger 日志
func NewGLogger ¶
NewGLogger 新建logger
type GONE_CONFIG_CONTENT ¶
type GONE_CONFIG_CONTENT []byte // 配置文件内容,可通过 embed 嵌入
type GONE_TLS_CERT ¶
type GONE_TLS_CERT string // https证书文件路径
type GONE_TLS_KEY ¶
type GONE_TLS_KEY string // https密钥文件路径
type IFileConfig ¶
type IFileConfig interface { ParseFile(name string) error ParseContent(data []byte) error IsValid(name string) bool }
IFileConfig 文件配置
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
RouterGroup 路由分组
func (*RouterGroup) After ¶
func (group *RouterGroup) After(afters ...func(ctx *Context) IResponse)
After 添加后置处理拦截器
func (*RouterGroup) Before ¶
func (group *RouterGroup) Before(befores ...func(ctx *Context) IResponse)
Before 添加拦截
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher 文件监听
由于syscall只支持 linux 系统,所以该监控只在 linux 下有效,windows下无法使用
跨平台的解决方案似乎应该使用 golang.org/x/sys
func NewWatcher ¶
NewWather 创建Watcher
默认监听 basePath 及其下所有目录,忽略隐藏文件。可通过 includes 和 excludes 来强制添加和排除监听
type WebEngine ¶
type WebEngine struct { *RouterGroup // contains filtered or unexported fields }
WebEngine http引擎,将作为http.Handler
Click to show internal directories.
Click to hide internal directories.