Documentation
¶
Index ¶
- Constants
- Variables
- func AbortWithJSONError(c *gin.Context, code int, err error)
- func GetDbConnection(c *gin.Context, objFn GetDB, isCreate bool) (tx *gorm.DB)
- func GetRenderPageContext(c *gin.Context) map[string]any
- func HintAssetsRoot(dirName string) string
- func NewTemplateFuncs() template.FuncMap
- func RegisterObject(r *gin.RouterGroup, obj *WebObject) error
- func RegisterObjects(r *gin.RouterGroup, objs []WebObject)
- func RenderNotFoundPage(c *gin.Context, path, method string)
- func SanitizeSensitiveValues(prefix string, data any) map[string]any
- func WithAdminAssets(r *gin.Engine, adminPrefix, adminRootDir string) gin.HandlerFunc
- func WithStaticAssets(r *gin.Engine, staticPrefix, staticRootDir string) gin.HandlerFunc
- type BeforeCreateFunc
- type BeforeDeleteFunc
- type BeforeQueryRenderFunc
- type BeforeRenderFunc
- type BeforeUpdateFunc
- type CombineEmbedFS
- type CombineTemplates
- type DebugTempalte
- type EmbedFS
- type EmbedFile
- type ErrorWithCode
- type Filter
- type GetDB
- type Order
- type PrepareQuery
- type QueryForm
- type QueryResult
- type QueryView
- type WebObject
- type WebObjectPrimaryField
Constants ¶
View Source
const ( FilterOpIsNot = "is not" FilterOpEqual = "=" FilterOpNotEqual = "<>" FilterOpIn = "in" FilterOpNotIn = "not_in" FilterOpGreater = ">" FilterOpGreaterOrEqual = ">=" FilterOpLess = "<" FilterOpLessOrEqual = "<=" FilterOpLike = "like" FilterOpBetween = "between" )
View Source
const ( OrderOpDesc = "desc" OrderOpAsc = "asc" )
View Source
const ( GET = 1 << 1 CREATE = 1 << 2 EDIT = 1 << 3 DELETE = 1 << 4 QUERY = 1 << 5 )
View Source
const (
DefaultQueryLimit = 102400 // 100k
)
Variables ¶
View Source
var EmbedAdminAssets embed.FS
View Source
var EmbedStaticAssets embed.FS
View Source
var GroupInvitationHTML string
View Source
var PasswordResetHTML string
View Source
var SystemNotFoundHTML string
View Source
var VerificationEmailHTML string
View Source
var VerificationHTML string
View Source
var WelcomeHTML string
Functions ¶
func GetDbConnection ¶
func HintAssetsRoot ¶
func NewTemplateFuncs ¶
func RegisterObject ¶
func RegisterObject(r *gin.RouterGroup, obj *WebObject) error
func RegisterObjects ¶
func RegisterObjects(r *gin.RouterGroup, objs []WebObject)
func RenderNotFoundPage ¶
RenderNotFoundPage 渲染 404 页面
func WithAdminAssets ¶
func WithAdminAssets(r *gin.Engine, adminPrefix, adminRootDir string) gin.HandlerFunc
func WithStaticAssets ¶
func WithStaticAssets(r *gin.Engine, staticPrefix, staticRootDir string) gin.HandlerFunc
Types ¶
type BeforeQueryRenderFunc ¶
type BeforeRenderFunc ¶
type BeforeUpdateFunc ¶
type CombineEmbedFS ¶
type CombineEmbedFS struct {
// contains filtered or unexported fields
}
func NewCombineEmbedFS ¶
func NewCombineEmbedFS(assertDir string, es ...EmbedFS) *CombineEmbedFS
type CombineTemplates ¶
type CombineTemplates struct {
CombineFS *CombineEmbedFS
Template *template.Template
Delims render.Delims
FuncMap template.FuncMap
}
func NewCombineTemplates ¶
func NewCombineTemplates(combineFS *CombineEmbedFS) *CombineTemplates
func (*CombineTemplates) Instance ¶
func (c *CombineTemplates) Instance(name string, ctx any) render.Render
Instance gin.render.Render
func (*CombineTemplates) RenderError ¶
type DebugTempalte ¶
type DebugTempalte struct {
Template *template.Template
Name string
Data any
// contains filtered or unexported fields
}
HTML contains template reference and its name with given interface object.
func (DebugTempalte) Render ¶
func (r DebugTempalte) Render(w http.ResponseWriter) error
Render (HTML) executes template and writes its result with custom ContentType for response.
func (DebugTempalte) WriteContentType ¶
func (r DebugTempalte) WriteContentType(w http.ResponseWriter)
WriteContentType (HTML) writes HTML ContentType.
type EmbedFile ¶
type EmbedFile struct {
// contains filtered or unexported fields
}
type ErrorWithCode ¶
type ErrorWithCode interface {
StatusCode() int
}
type Filter ¶
type PrepareQuery ¶
type QueryForm ¶
type QueryForm struct {
Pos int `json:"pos"`
Limit int `json:"limit"`
Keyword string `json:"keyword,omitempty"`
Filters []Filter `json:"filters,omitempty"`
Orders []Order `json:"orders,omitempty"`
ForeignMode bool `json:"foreign"` // for foreign key
ViewFields []string `json:"-"` // for view
// contains filtered or unexported fields
}
type QueryResult ¶
type QueryView ¶
type QueryView struct {
Path string `json:"path"`
Method string `json:"method"`
Desc string `json:"desc"`
Prepare PrepareQuery
}
type WebObject ¶
type WebObject struct {
Model any
Group string
Name string
Desc string
AuthRequired bool
Editables []string
Filterables []string
Orderables []string
Searchables []string
GetDB GetDB
PrepareQuery PrepareQuery
BeforeCreate BeforeCreateFunc
BeforeUpdate BeforeUpdateFunc
BeforeDelete BeforeDeleteFunc
BeforeRender BeforeRenderFunc
BeforeQueryRender BeforeQueryRenderFunc
Views []QueryView
AllowMethods int
// contains filtered or unexported fields
}
func (*WebObject) BuildPrimaryPath ¶
func (*WebObject) RegisterObject ¶
func (obj *WebObject) RegisterObject(r *gin.RouterGroup) error
Click to show internal directories.
Click to hide internal directories.