generate

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputAttributeNameStructTag     = "name"
	InputAttributeTemplateStructTag = "template"
)
View Source
const (
	TemplateDataFieldIdentifierResult        = "result"
	TemplateDataFieldIdentifierOkay          = "okay"
	TemplateDataFieldIdentifierRedirectURL   = "redirectURL"
	TemplateDataFieldIdentifierError         = "errList"
	TemplateDataFieldIdentifierReceiver      = "receiver"
	TemplateDataFieldIdentifierStatusCode    = "statusCode"
	TemplateDataFieldIdentifierErrStatusCode = "errStatusCode"
)

Variables

This section is empty.

Functions

func FileArguments

func FileArguments(workingDirectory, routesFunction string) (map[string][]string, error)

FileArguments scans the working directory for muxt-generated Go files.

Files are identified by: 1. Having a "// Code generated by muxt generate" comment on the first line 2. Matching the routes function name extracted from the generation comment

Returns a map of absolute file paths and the muxt arguments passed to generate them.

func GenerateValidations

func GenerateValidations(im astgen.ImportManager, variable ast.Expr, variableType types.Type, inputQuery, inputName, responseIdent string, fragment spec.DocumentFragment, validationFailureBlock ValidationErrorBlock) ([]ast.Stmt, error, bool)

Types

type AssertionFailureReporter

type AssertionFailureReporter struct{}

func (AssertionFailureReporter) Errorf

func (AssertionFailureReporter) Errorf(format string, args ...interface{})

type File

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

func (*File) Import

func (file *File) Import(pkgIdent, pkgPath string) string

func (*File) ImportSpecs

func (file *File) ImportSpecs() []*ast.ImportSpec

func (*File) OutputPackage

func (file *File) OutputPackage() *packages.Package

func (*File) Package

func (file *File) Package(path string) (*packages.Package, bool)

func (*File) StructField

func (file *File) StructField(pos token.Pos) (*ast.Field, error)

func (*File) SyntaxFile

func (file *File) SyntaxFile(pos token.Pos) (*ast.File, *token.FileSet, error)

func (*File) TypeASTExpression

func (file *File) TypeASTExpression(tp types.Type) (ast.Expr, error)

func (*File) Types

func (file *File) Types(pkgPath string) (*types.Package, bool)

type GeneratedFile

type GeneratedFile struct {
	Path    string
	Content string
}

func TemplateRoutesFile

func TemplateRoutesFile(wd string, config RoutesFileConfiguration, fileSet *token.FileSet, pl []*packages.Package, logger *log.Logger) ([]GeneratedFile, error)

type MaxLengthValidation

type MaxLengthValidation struct {
	Name      string
	MaxLength int
}

func (MaxLengthValidation) GenerateValidation

func (val MaxLengthValidation) GenerateValidation(_ astgen.ImportManager, variable ast.Expr, handleError ValidationErrorBlock) ast.Stmt

type MaxValidation

type MaxValidation struct {
	Name   string
	MinExp ast.Expr
}

func (MaxValidation) GenerateValidation

func (val MaxValidation) GenerateValidation(_ astgen.ImportManager, variable ast.Expr, handleError ValidationErrorBlock) ast.Stmt

type MinLengthValidation

type MinLengthValidation struct {
	Name      string
	MinLength int
}

func (MinLengthValidation) GenerateValidation

func (val MinLengthValidation) GenerateValidation(_ astgen.ImportManager, variable ast.Expr, handleError ValidationErrorBlock) ast.Stmt

type MinValidation

type MinValidation struct {
	Name   string
	MinExp ast.Expr
}

func (MinValidation) GenerateValidation

func (val MinValidation) GenerateValidation(_ astgen.ImportManager, variable ast.Expr, handleError ValidationErrorBlock) ast.Stmt

type PatternValidation

type PatternValidation struct {
	Name string
	Exp  *regexp.Regexp
}

func (PatternValidation) GenerateValidation

func (val PatternValidation) GenerateValidation(im astgen.ImportManager, variable ast.Expr, handleError ValidationErrorBlock) ast.Stmt

type RoutesFileConfiguration

type RoutesFileConfiguration struct {
	MuxtVersion,
	PackageName,
	PackagePath,
	TemplatesVariable,
	RoutesFunction,
	ReceiverType,
	ReceiverPackage,
	ReceiverInterface,
	TemplateDataType,
	TemplateRoutePathsTypeName string
	OutputFileName      string
	PathPrefix          bool
	Logger              bool
	Verbose             bool
	OutputMultipleFiles bool
	HTMXHelpers         bool
}

type ValidationErrorBlock

type ValidationErrorBlock func(string) *ast.BlockStmt

type ValidationGenerator

type ValidationGenerator interface {
	GenerateValidation(im astgen.ImportManager, variable ast.Expr, handleError ValidationErrorBlock) ast.Stmt
}

func ParseInputValidations

func ParseInputValidations(name string, input spec.Element, tp types.Type) ([]ValidationGenerator, error)

Jump to

Keyboard shortcuts

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