controller

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(state *State) ([]byte, error)

Generate the controller template from state

Types

type Action

type Action struct {
	Name        string
	Pascal      string
	Camel       string
	Short       string
	View        *View
	Key         string // Key is an extension-less path
	Route       string // Route to this action
	Redirect    string
	Method      string
	Provider    *di.Provider
	Params      []*ActionParam
	HandlerFunc bool
	Input       string
	Results     ActionResults
	RespondJSON bool
	RespondHTML bool
	PropsKey    string
}

Action is the target action state

type ActionParam

type ActionParam struct {
	Name     string
	Pascal   string
	Snake    string
	Type     string
	Kind     string
	Variable string
	Tag      string
}

ActionParam struct

func (*ActionParam) IsContext

func (ap *ActionParam) IsContext() bool

type ActionResult

type ActionResult struct {
	Name     string
	Pascal   string
	Named    bool
	Snake    string
	Type     string
	Kind     parser.Kind
	Variable string
	IsError  bool
	Fields   []*ActionResultField
	Methods  []*ActionResultMethod
}

ActionResult struct

type ActionResultField

type ActionResultField struct {
	Name string
	Type string
	Tag  string
}

ActionResultField struct

type ActionResultMethod

type ActionResultMethod struct {
}

ActionResultMethod struct

type ActionResults

type ActionResults []*ActionResult

ActionResults fn

func (ActionResults) Error

func (results ActionResults) Error() string

Error expression if there is one

func (ActionResults) IsOnlyError

func (results ActionResults) IsOnlyError() bool

Error expression is only return

func (ActionResults) Result

func (results ActionResults) Result() string

Result expression if there is one

func (ActionResults) Set

func (results ActionResults) Set() string

Set helper

func (ActionResults) ViewResult

func (results ActionResults) ViewResult() string

type Controller

type Controller struct {
	Name        string
	Pascal      string
	JSON        string
	Path        string // Path to controller without action dir
	Route       string
	Actions     []*Action
	Controllers []*Controller
}

Controller is the target controller state

func (*Controller) Last

func (c *Controller) Last() Name

type Generator

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

Generator for controllers

func New

func New(injector *di.Injector, module *gomod.Module, parser *parser.Parser) *Generator

New controller generator

func (*Generator) GenerateFile

func (g *Generator) GenerateFile(fsys genfs.FS, file *genfs.File) error

type Name

type Name string

func (Name) Pascal

func (n Name) Pascal() string

type State

type State struct {
	Imports    []*imports.Import
	Controller *Controller
	Providers  []*di.Provider
}

func Load

func Load(fsys fs.FS, injector *di.Injector, module *gomod.Module, parser *parser.Parser) (*State, error)

type View

type View struct {
	Route string
}

View struct

Directories

Path Synopsis
controllerrt

Jump to

Keyboard shortcuts

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