gen

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DFSPath

func DFSPath(root *RouteNode, target string) [][]string

DFS搜索路径

Types

type APIGenBuilder

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

func NewAPIGenBuilder

func NewAPIGenBuilder() *APIGenBuilder

func (*APIGenBuilder) AddRouter

func (b *APIGenBuilder) AddRouter(routerFile, groupFunc string) error

func (*APIGenBuilder) Build

func (b *APIGenBuilder) Build()

func (*APIGenBuilder) WithConfig

func (b *APIGenBuilder) WithConfig(configFile string) *APIGenBuilder

func (*APIGenBuilder) WithHandlerFunc

func (b *APIGenBuilder) WithHandlerFunc(handlerFile string) *APIGenBuilder

func (*APIGenBuilder) WithLogicFunc

func (b *APIGenBuilder) WithLogicFunc(logicFile string) *APIGenBuilder

func (*APIGenBuilder) WithTypeInfo

func (b *APIGenBuilder) WithTypeInfo(typeFile, apiPath string) *APIGenBuilder

type AddRouterHandler

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

添加路由的处理者

func (*AddRouterHandler) Handle

func (h *AddRouterHandler) Handle(data *APIGenBuilder)

func (*AddRouterHandler) SetNext

func (h *AddRouterHandler) SetNext(next HandlerChain) HandlerChain

type AnnotationData

type AnnotationData struct {
	Auth        bool
	HandlerName string
	ParamType   string
	Req         string
	Resp        string
	Group       string
	Path        string
	Method      string
	Summary     string
}

type ApiInfo

type ApiInfo struct {
	Path        string
	Method      string
	HandlerName string
	Auth        bool
	Group       string
	Summary     string
}

func ParseComments

func ParseComments(comment string) (info ApiInfo)

type Config

type Config struct {
	ApiPath  []string `yaml:"apiPath"`
	TypeFile string   `yaml:"typeFile"`

	Logic struct {
		File     string `yaml:"file"`
		Receiver string `yaml:"receiver"`
	} `yaml:"logic"`

	Handler struct {
		File string `yaml:"file"`
	} `yaml:"handler"`

	Router struct {
		File      string `yaml:"file"`
		GroupFunc string `yaml:"groupFunc"`
	} `yaml:"router"`
}

type FuncInfo

type FuncInfo struct {
	Pkg      string
	FuncName string
	Results  []string
}

func WriteDecl

func WriteDecl(filename, decl string) (info FuncInfo)

type GenHandlerFuncHandler

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

生成处理函数的处理者

func (*GenHandlerFuncHandler) Handle

func (h *GenHandlerFuncHandler) Handle(data *APIGenBuilder)

func (*GenHandlerFuncHandler) SetNext

type GenLogicFuncHandler

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

生成逻辑函数的处理者

func (*GenLogicFuncHandler) Handle

func (h *GenLogicFuncHandler) Handle(data *APIGenBuilder)

func (*GenLogicFuncHandler) SetNext

type HandlerChain

type HandlerChain interface {
	SetNext(HandlerChain) HandlerChain // 设置下一个处理者
	Handle(*APIGenBuilder)             // 处理请求
}

定义处理链的接口

type ParseTypesHandler

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

解析类型的处理者

func (*ParseTypesHandler) Handle

func (h *ParseTypesHandler) Handle(data *APIGenBuilder)

func (*ParseTypesHandler) SetNext

func (h *ParseTypesHandler) SetNext(next HandlerChain) HandlerChain

type RouteNode

type RouteNode struct {
	Caller   string
	Path     string
	Children []*RouteNode
}

func BuildRouteTree

func BuildRouteTree(routerFile, routerFunc string) (*RouteNode, error)

type RouterExprInfo

type RouterExprInfo struct {
	RG         string
	Method     string
	PathArg    string
	HandlerArg struct {
		HandlerPkg  string
		HandlerFunc string
	}
}

type TypeInfo

type TypeInfo struct {
	Req     string
	Resp    string
	PkgName string
	ApiInfo
}

Jump to

Keyboard shortcuts

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