codegen

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package codegen generates Go code from parsed handler information using extractors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator generates wrapper code for handlers using http.Handler

func New

func New() (*Generator, error)

New creates a new code generator for http.Handler (default)

func NewWithFramework

func NewWithFramework(framework string) (*Generator, error)

NewWithFramework creates a new code generator for the specified framework Supported frameworks: http (default), fiber, gin, echo

func (*Generator) Generate

func (g *Generator) Generate(result *parser.ParseResult) ([]byte, error)

Generate creates wrapper code for the given handlers

type HandlerData

type HandlerData struct {
	Name              string
	WrapperName       string
	ParseFuncName     string
	ParamType         string
	ReturnType        string
	HasExtractionCode bool
	ExtractionCode    string
	HasBody           bool
	BodyFieldName     string
	HasRawBody        bool
	RawBodyFieldName  string
	HasValidation     bool
	HasResponseWriter bool
	HasRequest        bool
	HasMultipartForm  bool
	MaxMemory         int64 // Max memory for multipart form parsing (default 32MB)
}

HandlerData holds data for a single handler

type TemplateData

type TemplateData struct {
	PackageName string
	Imports     []string
	Handlers    []HandlerData
	Framework   string
}

TemplateData holds data for template execution

Jump to

Keyboard shortcuts

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