Documentation
¶
Overview ¶
Package servergen generates zero-reflection transport codecs (request binding, validation, and response serialization) for typed server routes by analysing server.Register calls with go/packages. The codecs are an optimization: routes bind and serialize via a reflection fallback without them, so running `tyche generate` is never required — it just removes reflection from the hot path. Types declared in package main are keyed to match Go's runtime reflection, so single-file main.go apps work too.
Index ¶
- Constants
- func CleanupGeneratedFiles(rootDir string, patterns []string, keep map[string]struct{}) error
- func FindPackageDir(routes []RouteSpec, pkgPath string) (string, bool)
- func GeneratePackageManifest(pkgPath string, routes []RouteSpec) ([]byte, error)
- func GroupRoutesByPackage(routes []RouteSpec) map[string][]RouteSpec
- func WriteGeneratedFiles(dir string, patterns []string) error
- type BindFieldSpec
- type BodyBindSpec
- type BodyFieldSpec
- type BodyRequiredFieldSpec
- type HeaderFieldSpec
- type InputBindSpec
- type OutputBodyFieldSpec
- type OutputBodySpec
- type OutputWriteSpec
- type RouteSpec
Constants ¶
View Source
const GeneratedFilename = "zz_server_routes_gen.go"
Variables ¶
This section is empty.
Functions ¶
func CleanupGeneratedFiles ¶
func GeneratePackageManifest ¶
func GroupRoutesByPackage ¶
func WriteGeneratedFiles ¶
Types ¶
type BindFieldSpec ¶
type BodyBindSpec ¶
type BodyBindSpec struct {
Direct *BodyFieldSpec
Target string
DecodeTarget string
Fields []BodyFieldSpec
Required bool
}
type BodyFieldSpec ¶
type BodyFieldSpec struct {
ElemNested *BodyBindSpec
Nested *BodyBindSpec
NestedType string
JSONName string
TypeExpr string
Kind string
ElemStruct string
ElemKind string
ElemType string
FieldName string
Rules validation.FieldRules
NestedPtr bool
Required bool
Opaque bool
ElemPtr bool
Slice bool
Pointer bool
ElemStructPtr bool
}
type BodyRequiredFieldSpec ¶
func RequiredJSONFieldsForBodySpec ¶
func RequiredJSONFieldsForBodySpec(body *BodyBindSpec) []BodyRequiredFieldSpec
type HeaderFieldSpec ¶
type InputBindSpec ¶
type InputBindSpec struct {
Body *BodyBindSpec
Fields []BindFieldSpec
Manual bool
}
type OutputBodyFieldSpec ¶
type OutputBodySpec ¶
type OutputBodySpec struct {
TargetExpr string
Fields []OutputBodyFieldSpec
HasSimpleStatus bool
}
type OutputWriteSpec ¶
type OutputWriteSpec struct {
Body *OutputBodySpec
BodyFieldName string
BodyTypeExpr string
StatusField string
Headers []HeaderFieldSpec
StaticStatus int
Manual bool
}
type RouteSpec ¶
type RouteSpec struct {
PackageName string
Path string
ServerImportPath string
OperationID string
Method string
InputType string
OutputType string
InputTypeKey string
OutputTypeKey string
ResponseContentTypes []string
Dir string
PackagePath string
InputBind InputBindSpec
OutputWrite OutputWriteSpec
}
func LoadRoutes ¶
Click to show internal directories.
Click to hide internal directories.