Documentation ¶
Index ¶
- Constants
- Variables
- func CheckParam1MustBeContext(rpcType *ast.FuncType) error
- func CheckResult2MustBeError(rpcType *ast.FuncType) error
- func CleanPackageName(name string) string
- func ExtractDescription(field *ast.Field) string
- func ExtractGoImports(serviceFile *ast.File) map[string]*GoImport
- func ExtractValue(s string, annotation string) (string, bool)
- func FindWildcard(path string) (wildcard string, i int, valid bool)
- func FindWildcards(path string) ([]string, error)
- func FullMethodName(serviceFullName string, methodName string) string
- func Inspect(pkg *packages.Package, serviceName string) (*ast.File, *ast.GenDecl, *ast.TypeSpec, *ast.InterfaceType, []*ast.Field)
- func LoadPkg(args []string) (*packages.Package, error)
- type Binding
- type GoIdent
- type GoImport
- type GoImportPath
- type Method
- type ObjectArgs
- type Param
- type Render
- type Result
- type RouterInfo
- func ExtractRouterInfo(method *ast.Field) (*RouterInfo, error)
- func ParseRouter(comments []string) (*RouterInfo, error)
- func ParseRouterInfo(method *ast.Field, imports map[string]*GoImport) (*RouterInfo, error)
- func ParseRouterInfos(rpcMethods []*ast.Field, serviceInfo *ServiceInfo, pathToLower bool) ([]*RouterInfo, error)
- func (router *RouterInfo) DefaultBindingName()
- func (router *RouterInfo) DefaultHttpMethod()
- func (router *RouterInfo) DefaultHttpPath(pathToLower bool)
- func (router *RouterInfo) DefaultRenderName()
- func (router *RouterInfo) SetFullMethodName(rpcMethodName string)
- func (router *RouterInfo) SetFuncType(rpcType *ast.FuncType)
- func (router *RouterInfo) SetHandlerName(serviceName string)
- func (router *RouterInfo) SetMethodName(name string)
- func (router *RouterInfo) SetParam2(param *Param)
- func (router *RouterInfo) SetResult1(result *Result)
- func (router *RouterInfo) SetServiceInfo(info *ServiceInfo)
- type ServiceInfo
- func NewService(comments []string) (*ServiceInfo, error)
- func ParseService(args []string, serviceName string, pathToLower bool) (*ServiceInfo, error)
- func ParseServiceFromPb(service *protogen.Service, pathToLower bool) (*ServiceInfo, error)
- func ParseServiceInfo(serviceDecl *ast.GenDecl) (*ServiceInfo, error)
- func (info *ServiceInfo) SetFullName(name string)
- func (info *ServiceInfo) SetImports(imports map[string]*GoImport)
- func (info *ServiceInfo) SetOutDir(dir string)
- func (info *ServiceInfo) SetPackageName(name string)
- func (info *ServiceInfo) SetPkgPath(pkgPath string)
- func (info *ServiceInfo) SetRouters(routers []*RouterInfo)
- func (info *ServiceInfo) SetServiceName(s string)
Constants ¶
View Source
const ( GORS = "@GORS" Path = "@Path" GET Method = "@GET" POST Method = "@POST" PUT Method = "@PUT" DELETE Method = "@DELETE" PATCH Method = "@PATCH" HEAD Method = "@HEAD" CONNECT Method = "@CONNECT" OPTIONS Method = "@OPTIONS" TRACE Method = "@TRACE" ReaderBinding Binding = "@ReaderBinding" BytesBinding Binding = "@BytesBinding" StringBinding Binding = "@StringBinding" UriBinding Binding = "@UriBinding" QueryBinding Binding = "@QueryBinding" HeaderBinding Binding = "@HeaderBinding" JSONBinding Binding = "@JSONBinding" XMLBinding Binding = "@XMLBinding" FormBinding Binding = "@FormBinding" FormPostBinding Binding = "@FormPostBinding" FormMultipartBinding Binding = "@FormMultipartBinding" ProtoBufBinding Binding = "@ProtoBufBinding" MsgPackBinding Binding = "@MsgPackBinding" YAMLBinding Binding = "@YAMLBinding" TOMLBinding Binding = "@TOMLBinding" ProtoJSONBinding Binding = "@ProtoJSONBinding" CustomBinding Binding = "@CustomBinding" ReaderRender Render = "@ReaderRender" BytesRender Render = "@BytesRender" StringRender Render = "@StringRender" TextRender Render = "@TextRender" HTMLRender Render = "@HTMLRender" RedirectRender Render = "@RedirectRender" JSONRender Render = "@JSONRender" IndentedJSONRender Render = "@IndentedJSONRender" SecureJSONRender Render = "@SecureJSONRender" JSONPJSONRender Render = "@JSONPJSONRender" PureJSONRender Render = "@PureJSONRender" AsciiJSONRender Render = "@AsciiJSONRender" ProtoJSONRender Render = "@ProtoJSONRender" XMLRender Render = "@XMLRender" YAMLRender Render = "@YAMLRender" ProtoBufRender Render = "@ProtoBufRender" MsgPackRender Render = "@MsgPackRender" TOMLRender Render = "@TOMLRender" CustomRender Render = "@CustomRender" )
The list of annotation.
View Source
const ( BinaryContentType = "application/octet-stream" PlainContentType = "text/plain" HTMLContentType = "text/html" JSONContentType = "application/json" JSONPContentType = "application/javascript" XMLContentType = "application/xml" XML2ContentType = "text/xml" FormContentType = "application/x-www-form-urlencoded" FormMultipartContentType = "multipart/form-data" ProtoBufContentType = "application/x-protobuf" MsgPackContentType = "application/x-msgpack" MsgPack2ContentType = "application/msgpack" YAMLContentType = "application/x-yaml" TOMLContentType = "application/toml" )
Content-Type
Variables ¶
View Source
var ( ErrMultipleBodyBinding = errors.New("there are multiple body binding") ErrMultipleHttpMethod = errors.New("there are multiple methods") )
View Source
var Err1thParam = errors.New("error: 1th param is not context.Context")
View Source
var Err2thResult = errors.New("error: 2th result is not error")
View Source
var ErrFuncType = errors.New("failed convert to *ast.FuncType")
View Source
var ErrParamType = errors.New("error: param is invalid, must be []byte or string or io.Reader or *struct{}")
View Source
var ErrParamsInvalid = fmt.Errorf("error: params invalid")
View Source
var ErrPathInvalid = errors.New("path invalid")
View Source
var ErrResultType = errors.New("error: 1th result is invalid, must be []byte or string or io.Reader or *struct{}")
View Source
var ErrResultsInvalid = fmt.Errorf("error: results invalid")
Functions ¶
func CheckParam1MustBeContext ¶ added in v1.5.0
func CheckResult2MustBeError ¶ added in v1.5.0
func CleanPackageName ¶ added in v1.5.0
func ExtractDescription ¶ added in v1.5.0
func ExtractGoImports ¶ added in v1.5.0
func FindWildcard ¶ added in v1.5.0
FindWildcard Search for a wildcard segment and check the name for invalid characters. Returns -1 as index, if no wildcard was found.
func FindWildcards ¶ added in v1.5.0
func FullMethodName ¶ added in v1.5.0
Types ¶
type GoImportPath ¶ added in v1.5.0
type GoImportPath string
func (GoImportPath) Ident ¶ added in v1.5.0
func (p GoImportPath) Ident(s string) *GoIdent
type Method ¶
type Method string
func (Method) EqualsIgnoreCase ¶
func (Method) HttpMethod ¶
func (Method) HttpMethodName ¶ added in v1.5.0
type ObjectArgs ¶ added in v1.5.0
type ObjectArgs struct { Name string GoImportPath GoImportPath StarExpr *ast.StarExpr }
type Param ¶ added in v1.5.0
type Param struct { Bytes bool String bool ObjectArgs *ObjectArgs Reader bool }
func CheckAndGetParam2 ¶ added in v1.5.0
type Result ¶ added in v1.5.0
type Result struct { Bytes bool String bool ObjectArgs *ObjectArgs Reader bool }
func CheckAndGetResult1 ¶ added in v1.5.0
type RouterInfo ¶
type RouterInfo struct { HttpMethod Method Description string Path string MethodName string FullMethodName string BindingContentType string Bindings []Binding RenderContentType string Render Render HandlerName string ProtoMethod *protogen.Method FuncType *ast.FuncType Param2 *Param Result1 *Result UriParams []string QueryParams []string HeaderParams []string ServiceInfo *ServiceInfo }
func ExtractRouterInfo ¶ added in v1.5.0
func ExtractRouterInfo(method *ast.Field) (*RouterInfo, error)
func ParseRouter ¶ added in v1.5.0
func ParseRouter(comments []string) (*RouterInfo, error)
func ParseRouterInfo ¶ added in v1.5.0
func ParseRouterInfos ¶ added in v1.5.0
func ParseRouterInfos(rpcMethods []*ast.Field, serviceInfo *ServiceInfo, pathToLower bool) ([]*RouterInfo, error)
func (*RouterInfo) DefaultBindingName ¶ added in v1.5.0
func (router *RouterInfo) DefaultBindingName()
func (*RouterInfo) DefaultHttpMethod ¶ added in v1.5.0
func (router *RouterInfo) DefaultHttpMethod()
func (*RouterInfo) DefaultHttpPath ¶ added in v1.5.0
func (router *RouterInfo) DefaultHttpPath(pathToLower bool)
func (*RouterInfo) DefaultRenderName ¶ added in v1.5.0
func (router *RouterInfo) DefaultRenderName()
func (*RouterInfo) SetFullMethodName ¶ added in v1.5.0
func (router *RouterInfo) SetFullMethodName(rpcMethodName string)
func (*RouterInfo) SetFuncType ¶ added in v1.5.0
func (router *RouterInfo) SetFuncType(rpcType *ast.FuncType)
func (*RouterInfo) SetHandlerName ¶ added in v1.5.0
func (router *RouterInfo) SetHandlerName(serviceName string)
func (*RouterInfo) SetMethodName ¶ added in v1.5.0
func (router *RouterInfo) SetMethodName(name string)
func (*RouterInfo) SetParam2 ¶ added in v1.5.0
func (router *RouterInfo) SetParam2(param *Param)
func (*RouterInfo) SetResult1 ¶ added in v1.5.0
func (router *RouterInfo) SetResult1(result *Result)
func (*RouterInfo) SetServiceInfo ¶ added in v1.5.0
func (router *RouterInfo) SetServiceInfo(info *ServiceInfo)
type ServiceInfo ¶
type ServiceInfo struct { Name string Description string BasePath string Routers []*RouterInfo FullName string PackageName string OutDir string PkgPath string Imports map[string]*GoImport }
func NewService ¶
func NewService(comments []string) (*ServiceInfo, error)
func ParseService ¶ added in v1.5.0
func ParseService(args []string, serviceName string, pathToLower bool) (*ServiceInfo, error)
func ParseServiceFromPb ¶ added in v1.5.0
func ParseServiceFromPb(service *protogen.Service, pathToLower bool) (*ServiceInfo, error)
func ParseServiceInfo ¶ added in v1.5.0
func ParseServiceInfo(serviceDecl *ast.GenDecl) (*ServiceInfo, error)
func (*ServiceInfo) SetFullName ¶ added in v1.5.0
func (info *ServiceInfo) SetFullName(name string)
func (*ServiceInfo) SetImports ¶ added in v1.5.0
func (info *ServiceInfo) SetImports(imports map[string]*GoImport)
func (*ServiceInfo) SetOutDir ¶ added in v1.5.0
func (info *ServiceInfo) SetOutDir(dir string)
func (*ServiceInfo) SetPackageName ¶ added in v1.5.0
func (info *ServiceInfo) SetPackageName(name string)
func (*ServiceInfo) SetPkgPath ¶ added in v1.5.0
func (info *ServiceInfo) SetPkgPath(pkgPath string)
func (*ServiceInfo) SetRouters ¶ added in v1.5.0
func (info *ServiceInfo) SetRouters(routers []*RouterInfo)
func (*ServiceInfo) SetServiceName ¶ added in v1.5.0
func (info *ServiceInfo) SetServiceName(s string)
Click to show internal directories.
Click to hide internal directories.