hertz

package
v0.0.0-...-0bfb5ad Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendKey

type AppendKey string
const (
	AppendKeyMethod  AppendKey = "method"
	AppendKeyService AppendKey = "service"
)

func (AppendKey) IsValid

func (t AppendKey) IsValid() bool

func (AppendKey) String

func (t AppendKey) String() string

type BehaviorType

type BehaviorType string
const (
	Skip   BehaviorType = "skip"
	Cover  BehaviorType = "cover"
	Append BehaviorType = "append"
)

func (BehaviorType) IsValid

func (t BehaviorType) IsValid() bool

func (BehaviorType) String

func (t BehaviorType) String() string

type CustomizedFileForCustom

type CustomizedFileForCustom struct {
	FilePath    string
	FilePackage string
	Packages    parser.Packages
	Extras      Extras // from template
	FilePathRenderInfo
}

type CustomizedFileForIDL

type CustomizedFileForIDL struct {
	FilePath    string
	FilePackage string
	IdlInfo     *parser.File
	Extras      Extras // from template
	FilePathRenderInfo
}

type CustomizedFileForMethod

type CustomizedFileForMethod struct {
	FilePath     string
	FilePackage  string
	Method       *parser.HttpMethod
	ClientMethod *parser.ClientMethod
	Extras       Extras // from template
	FilePathRenderInfo
}

type CustomizedFileForPackage

type CustomizedFileForPackage struct {
	FilePath    string
	FilePackage string
	Package     *parser.Package
	Extras      Extras // from template
	FilePathRenderInfo
}

type CustomizedFileForService

type CustomizedFileForService struct {
	FilePath    string
	FilePackage string
	Service     *parser.Service
	Extras      Extras // from template
	FilePathRenderInfo
}

type Extras

type Extras map[string]string

func (Extras) Get

func (e Extras) Get(key string) string

type FilePathRenderInfo

type FilePathRenderInfo struct {
	ModuleDir   string // module dir
	GoModule    string // go module name
	IDLName     string // idl name, when template type is idl
	Namespace   string // namespace, when template type is package
	PackageName string // package name, when template type is  package
	ServiceName string // service name, when template type is service or method
	MethodName  string // method name, when template type is method
}

type GenerateConfig

type GenerateConfig struct {
	Templates []*Template       `json:"templates"`
	GoModule  string            `json:"go_module"`
	ModuleDir string            `json:"module_dir"`
	IDLType   generator.IdlType `json:"idl_type"`
	Files     []string          `json:"files"` // idl files, theses files will be used to generate the code
	Extras    Extras            `json:"extras"`
	Options   parser.Options    `json:"options"`
}

func (*GenerateConfig) UnmarshalJSON

func (config *GenerateConfig) UnmarshalJSON(data []byte) error

type GenerateMode

type GenerateMode string
const (
	Custom  GenerateMode = "custom"
	Package GenerateMode = "package"
	File    GenerateMode = "file"
	Service GenerateMode = "service"
	Method  GenerateMode = "method"
)

func (GenerateMode) IsValid

func (t GenerateMode) IsValid() bool

func (GenerateMode) String

func (t GenerateMode) String() string

type Generator

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

func NewGenerator

func NewGenerator(ctx context.Context, configFiles []string) (*Generator, error)

func (*Generator) Generate

func (g *Generator) Generate() error

func (*Generator) Name

func (g *Generator) Name() string

type Template

type Template struct {
	Path           string         `json:"path"`            // The generated path and its filename, such as biz/handler/ping.go
	Delims         [2]string      `json:"delims"`          // Template Action Instruction Identifier, default: "{{}}"
	Body           string         `json:"body"`            // Render template, currently only supports go template syntax
	Type           GenerateMode   `json:"type"`            // Template type: file/dir
	UpdateBehavior UpdateBehavior `json:"update_behavior"` // Update command behavior; 0:unchanged, 1:regenerate, 2:append
	Extras         Extras         `json:"extras"`          // Extra information
}

func (*Template) Preprocess

func (tpl *Template) Preprocess()

type UpdateBehavior

type UpdateBehavior struct {
	Type BehaviorType `json:"type"` // Update behavior type: skip/cover/append
	// the following variables are used for append update
	AppendKey AppendKey `json:"append_key"`         // Append content based in key; for example: 'method'/'service'
	InsertKey string    `json:"insert_key"`         // Insert content by "insert_key"
	AppendTpl string    `json:"append_content_tpl"` // Append content if UpdateBehavior is "append"
	ImportTpl []string  `json:"import_tpl"`         // Import insert template
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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