Documentation ¶
Index ¶
- Constants
- Variables
- func AddImport(f *ast.File, im string)
- func GenAssign(path, pPath string, mids *[]MWTuple) *ast.AssignStmt
- func GenTemplate() *ast.File
- func Generate(dirList ...string)
- func TraverseRawFuncList(list *[]RawFunc, h *[]HandlerFunc, m map[string]*MiddlewareFunc, ...)
- func WalkFileTree(from *FileTreeNode, to *[]RawFunc)
- type FileTreeNode
- type Func
- type GenContext
- type GroupTree
- type HandlerFunc
- type MWTuple
- type MiddlewareFunc
- type RawFunc
Constants ¶
View Source
const ( EngineName = "e" Tips = `` /* 342-byte string literal not displayed */ TemplateFile = ` package _example import ( "github.com/gin-gonic/gin" ) func Route(e *gin.Engine) { }` )
Variables ¶
View Source
var (
DefaultFileName = "route.entry.go"
)
Functions ¶
func GenTemplate ¶
func TraverseRawFuncList ¶
func TraverseRawFuncList(list *[]RawFunc, h *[]HandlerFunc, m map[string]*MiddlewareFunc, i map[string]bool)
TraverseRawFuncList traverses list of RawFunc and get handler list ,middleware map and imports list
func WalkFileTree ¶
func WalkFileTree(from *FileTreeNode, to *[]RawFunc)
WalkFileTree walk file tree and get the raw function
Types ¶
type FileTreeNode ¶
type FileTreeNode struct { PackagePath string Files map[string]*ast.File Children []*FileTreeNode }
func LoadFileTree ¶
func LoadFileTree(dir string) *FileTreeNode
LoadFileTree load disk file into a tree
func NewEmptyFileTree ¶
func NewEmptyFileTree() *FileTreeNode
type GenContext ¶
type GenContext struct { Root *GroupTree MiddlePool map[string]*MiddlewareFunc GroupPool map[string]*GroupTree }
func (*GenContext) InitGroupTree ¶
func (ctx *GenContext) InitGroupTree(middles map[string]*MiddlewareFunc, handles *[]HandlerFunc)
InitGroupTree with middlewares and handlers
func (*GenContext) PutHandler ¶
func (ctx *GenContext) PutHandler(h *HandlerFunc)
func (*GenContext) PutMiddleware ¶
func (ctx *GenContext) PutMiddleware(m *MiddlewareFunc)
type GroupTree ¶
type GroupTree struct { Path string // /c AbsPath string // /aaa/bbb/c Ctx *GenContext Parent *GroupTree Middles []MWTuple Handlers []*HandlerFunc Children map[string]*GroupTree }
func NewGroupTreeNode ¶
func NewGroupTreeNode(path, absPath string, ctx *GenContext, parent *GroupTree) *GroupTree
type HandlerFunc ¶
type HandlerFunc struct { RawFunc Group *GroupTree GroupArray []string // /user -> /name Need []string // middleware id Middles []*MiddlewareFunc Method string RelativePath string }
func (*HandlerFunc) GenAST ¶
func (h *HandlerFunc) GenAST() *ast.ExprStmt
type MWTuple ¶
type MWTuple struct { M *MiddlewareFunc W int }
Click to show internal directories.
Click to hide internal directories.