Documentation ¶
Index ¶
- Constants
- func Logus(format string, v ...interface{})
- func RegisterGenerators(gs ...Generator)
- func RegisterParsers(ps ...Parser)
- type Descriptors
- type EngineInfo
- type FieldDescriptor
- type Generator
- type GeneratorOpts
- type IfaceDescriptor
- type IfaceDescriptors
- type InitOpts
- type MirCtx
- type Option
- func Cleanup(enable bool) Option
- func DefaultTag(tag string) Option
- func EngineImportAlias(name string) Option
- func EnginePkgName(pkgName string) Option
- func GeneratorName(name string) Option
- func NoneQuery(enable bool) Option
- func ParserName(name string) Option
- func RunMode(mode runMode) Option
- func SinkPath(path string) Option
- type Options
- type Parser
- type ParserOpts
Constants ¶
const ( // run mode list InSerialMode runMode = iota InConcurrentMode InSerialDebugMode InConcurrentDebugMode // generator Names GeneratorGin = "gin" GeneratorChi = "chi" GeneratorMux = "mux" GeneratorEcho = "echo" GeneratorIris = "iris" GeneratorFiber = "fiber" GeneratorFiberV2 = "fiberV2" GeneratorMacaron = "macaron" GeneratorHttpRouter = "httprouter" // parser Names ParserStructTag = "structTag" )
Variables ¶
This section is empty.
Functions ¶
func RegisterGenerators ¶
func RegisterGenerators(gs ...Generator)
RegisterGenerators register generators
Types ¶
type Descriptors ¶
type Descriptors map[string]IfaceDescriptors
Descriptors mir's Descriptor map {group: IfaceDescriptors}
func (Descriptors) Exist ¶
func (d Descriptors) Exist(iface *IfaceDescriptor) bool
Exist whether exist *IfaceDescriptor sub-item
func (Descriptors) Get ¶
func (d Descriptors) Get(group string) (IfaceDescriptors, bool)
Get get a IfaceDescriptors if exists
func (Descriptors) GroupFrom ¶
func (d Descriptors) GroupFrom(key string) string
GroupFrom return group name from key
func (Descriptors) Put ¶
func (d Descriptors) Put(iface *IfaceDescriptor) error
Put add a IfaceDescriptor Notice: if exist same instance by TypeName will override the old one
type EngineInfo ¶ added in v2.5.0
EngineInfo Engine information
type FieldDescriptor ¶
type FieldDescriptor struct { Host string Path string Queries []string HttpMethod string MethodName string Comment string // not support now so always empty }
FieldDescriptor field Descriptor info
func (*FieldDescriptor) AnyHttpMethods ¶ added in v2.8.0
func (f *FieldDescriptor) AnyHttpMethods() []string
AnyHttpMethods return methods in HttpMethods Note this is assumed HttpMethods like ANY:POST,GET,HEAD
func (*FieldDescriptor) HttpMethodArgs ¶ added in v2.8.0
func (f *FieldDescriptor) HttpMethodArgs() string
HttpMethodArgs return http method as argument like "POST","GET","HEAD" Note this is assumed HttpMethods like ANY:POST,GET,HEAD
func (*FieldDescriptor) JustHttpAny ¶ added in v2.8.0
func (f *FieldDescriptor) JustHttpAny() bool
JustHttpAny not just http any method
func (*FieldDescriptor) NotHttpAny ¶ added in v2.8.0
func (f *FieldDescriptor) NotHttpAny() bool
NotHttpAny not just http any method
type Generator ¶
type Generator interface { Name() string Init(opts *GeneratorOpts) error Generate(Descriptors) error GenerateContext(ctx MirCtx) Clone() Generator }
Generator generate interface code for engine
func GeneratorByName ¶
GeneratorByName get a generator by name
type GeneratorOpts ¶ added in v2.3.0
GeneratorOpts used for initial generator
type IfaceDescriptor ¶
type IfaceDescriptor struct { Group string Chain string PkgName string TypeName string Comment string // not support now so always empty Fields []*FieldDescriptor EngineInfo *EngineInfo }
IfaceDescriptor interface Descriptor info
func (*IfaceDescriptor) SetPkgName ¶
func (d *IfaceDescriptor) SetPkgName(name string)
SetPkgName set package name
type IfaceDescriptors ¶
type IfaceDescriptors map[string]*IfaceDescriptor
IfaceDescriptors interface Descriptor map {TypeName:*IfaceDescriptor}
type InitOpts ¶
type InitOpts struct { RunMode runMode GeneratorName string ParserName string SinkPath string DefaultTag string EnginePkgName string EngineImportAlias string NoneQuery bool Cleanup bool }
InitOpts use for generator or parser init
func (*InitOpts) GeneratorOpts ¶ added in v2.3.0
func (opts *InitOpts) GeneratorOpts() *GeneratorOpts
GeneratorOpts return a GeneratorOpts
func (*InitOpts) ParserOpts ¶ added in v2.3.0
func (opts *InitOpts) ParserOpts() *ParserOpts
ParserOpts return a ParserOpts instance
type MirCtx ¶ added in v2.1.0
type MirCtx interface { context.Context Cancel(err error) ParserDone() GeneratorDone() Wait() error Capcity() int Pipe() (<-chan *IfaceDescriptor, chan<- *IfaceDescriptor) }
MirCtx mir's concurrent parser/generator context
type Option ¶ added in v2.3.0
type Option interface {
// contains filtered or unexported methods
}
Option pass option to custom run behavior
func DefaultTag ¶ added in v2.3.0
DefaultTag set parser's default struct field tag string key
func EngineImportAlias ¶ added in v2.5.0
EngineImportAlias import package alias name
func EnginePkgName ¶ added in v2.5.0
EnginePkgName engine package name
func GeneratorName ¶ added in v2.3.0
GeneratorName set generator name option
func ParserName ¶ added in v2.3.0
ParserName set parser name option
type Parser ¶
type Parser interface { Name() string Init(opts *ParserOpts) error Parse(entries []interface{}) (Descriptors, error) ParseContext(ctx MirCtx, entries []interface{}) Clone() Parser }
Parser parse entries
type ParserOpts ¶ added in v2.3.0
type ParserOpts struct { EngineInfo *EngineInfo DefaultTag string NoneQuery bool }
ParserOpts used for initial parser