Documentation ¶
Overview ¶
Package annotation parse annotation from source code file and recognize follows.
Comment @Handler("name", "pkg.ExampleHandler") to define handler and use @Middleware("name") to use it around Controller handler or route handler.
Index ¶
Constants ¶
const ( Description = "Build annotation files for middleware, crontab, controller etc" Name = "gen:annotation" OptAnnotationPath = "annotation-path" OptAnnotationPathDesc = "Generated files will be saved to" OptAnnotationPathShort = 'a' OptAnnotationPathDefaultValue = "app/annotations" OptControllerPath = "controller-path" OptControllerPathDesc = "Controller files location" OptControllerPathShort = 'c' OptControllerPathDefaultValue = "app/controllers" OptCrontabPath = "crontab-path" OptCrontabPathDesc = "Crontab files location" OptCrontabPathShort = 'r' OptCrontabPathDefaultValue = "app/crontabs" OptHandlerPath = "handler-path" OptHandlerPathDesc = "Handler files location" OptHandlerPathShort = 'h' OptHandlerPathDefaultValue = "app/handlers" OptMiddlewarePath = "middleware-path" OptMiddlewarePathDesc = "Middleware files location" OptMiddlewarePathShort = 'm' OptMiddlewarePathDefaultValue = "app/middlewares" OptOverride = "override" OptOverrideDesc = "Override existed file, Do nothing if not specified" OptWorkingDir = "working-dir" OptWorkingDirShort = 'w' OptWorkingDirDesc = "Current working dir is" OptWorkingDirDefaultValue = "./" )
Variables ¶
var (
BuilderVariables = regexp.MustCompile(`{{([^}]*)}}`)
)
Functions ¶
Types ¶
type ParseCrontab ¶
type ParseCrontab struct {
// contains filtered or unexported fields
}
ParseCrontab is a parser component used to parse crontab source code.
func (*ParseCrontab) Parse ¶
func (o *ParseCrontab) Parse(pkg, path string) error
Parse middleware files.
Param path is an absolute file path.
func (*ParseCrontab) Save ¶
func (o *ParseCrontab) Save() (err error)
Save parsed items into target file.
type ParseCrontabItem ¶
type ParseCrontabItem struct {
Pkg, Name string
GlobalUnique, NodeUnique bool
RunOnStart bool
Strategy string
}
ParseCrontabItem middleware parsed from source code.
ParseCrontabItem{ Pkg: "sketch/app/crontabs", Name: "ExampleCrontab", }
type ParseHandler ¶
type ParseHandler struct {
// contains filtered or unexported fields
}
ParseHandler is a parser component used to parse middleware source code.
func (*ParseHandler) Parse ¶
func (o *ParseHandler) Parse(pkg, path string) error
Parse middleware files.
Param path is an absolute file path.
func (*ParseHandler) Save ¶
func (o *ParseHandler) Save() (err error)
Save parsed items into target file.
type ParseHandlerItem ¶
type ParseHandlerItem struct {
Pkg, Name string
Method, Uri string
Middlewares []string
// contains filtered or unexported fields
}
ParseHandlerItem middleware parsed from source code.
ParseHandlerItem{ Key: "custom", Pkg: "sketch/app/middlewares", Name: "Example", }
type ParseMiddleware ¶
type ParseMiddleware struct {
// contains filtered or unexported fields
}
ParseMiddleware is a parser component used to parse middleware source code.
func (*ParseMiddleware) Parse ¶
func (o *ParseMiddleware) Parse(pkg, path string) error
Parse middleware files.
Param path is an absolute file path.
func (*ParseMiddleware) Save ¶
func (o *ParseMiddleware) Save() (err error)
Save parsed items into target file.
type ParseMiddlewareItem ¶
ParseMiddlewareItem middleware parsed from source code.
ParseMiddlewareItem{ Key: "custom", Pkg: "sketch/app/middlewares", Name: "Example", }
type Parser ¶
type Parser interface { // Parse // parses source code from any file path. // // .Parse( // "sketch/app/middlewares", // "/data/sketch/app/middlewares/example.go", // ) Parse(pkg, path string) (err error) // Save // parsed template to a file. Save() (err error) }
Parser is an interface for source code parse.