routes

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Repo   string            `json:"repo" yaml:"repo"`
	Name   string            `json:"name" yaml:"name"`
	Groups map[string]*Group `json:"groups" yaml:"groups"`
	Routes map[string]*Route `json:"routes" yaml:"routes"`
}

Definition stores the configuration from the routes file

func (*Definition) FindRoute

func (d *Definition) FindRoute(name string) *Route

FindRoute finds a route corresponding to the path name passed as argument

type Generator

type Generator struct {
	Config     *config.Config
	Definition *Definition
	Groups     []*GroupGenerator
}

Generator manages the generation of all routes related files

func NewGenerator

func NewGenerator(cfg *config.Config) *Generator

NewGenerator creates and returns an instance of Generator

func (*Generator) Execute

func (g *Generator) Execute() error

Execute generates the files from the templates

type Group

type Group struct {
	Repo   string            `json:"repo" yaml:"repo"`
	Name   string            `json:"name" yaml:"name"`
	Path   string            `json:"path" yaml:"path"`
	Method string            `json:"method" yaml:"method"`
	Routes map[string]*Route `json:"routes" yaml:"routes"`
	Rest   bool              `json:"rest" yaml:"rest"`
}

Group stores the configuration of the group

func (*Group) Camel

func (g *Group) Camel() string

type GroupGenerator

type GroupGenerator struct {
	*base.Generator
	Config     *config.Config
	Output     string
	Name       string
	Definition *Group
}

GroupGenerator manages the creation of group routes

func NewGroupGenerator

func NewGroupGenerator(cfg *config.Config, name string, d *Group) *GroupGenerator

NewGroupGenerator configures and returns an instance of GroupGenerator

func (*GroupGenerator) Execute

func (g *GroupGenerator) Execute() error

Execute manages creation of group routes files with the template

type Param

type Param struct {
	Name    string `json:"name" yaml:"name"`
	Type    string `json:"type" yaml:"type"`
	Default string `json:"default" yaml:"default"`
}

Param stores the configuration of the parameter

func (*Param) GetType

func (d *Param) GetType() string

GetType returns the capitalized type of the parameter or the default string

type Route

type Route struct {
	Repo   string   `json:"repo" yaml:"repo"`
	Name   string   `json:"name" yaml:"name"`
	Path   string   `json:"path" yaml:"path"`
	Method string   `json:"method" yaml:"method"`
	Params []*Param `json:"params" yaml:"params"`
}

Route stores the configuration of the route

func (*Route) Camel

func (r *Route) Camel() string

func (*Route) GetMethod

func (r *Route) GetMethod() string

GetMethod returns the capitalized method of the route or the default get

type ServerGenerator

type ServerGenerator struct {
	*base.Generator
	Config     *config.Config
	Output     string
	Definition *Definition
}

ServerGenerator manages the creation of the server file

func NewServerGenerator

func NewServerGenerator(cfg *config.Config, d *Definition) *ServerGenerator

NewServerGenerator creates and returns an instance of ServerGenerator

func (*ServerGenerator) Execute

func (g *ServerGenerator) Execute() error

Execute creates the server file from the template

type ServerRoutesGenerator

type ServerRoutesGenerator struct {
	*base.Generator
	Config     *config.Config
	Output     string
	Definition *Definition
}

ServerRoutesGenerator manages the creation of the server routes file

func NewServerRoutesGenerator

func NewServerRoutesGenerator(cfg *config.Config, d *Definition) *ServerRoutesGenerator

NewServerRoutesGenerator creates and returns an instance of ServerRoutesGenerator

func (*ServerRoutesGenerator) Execute

func (g *ServerRoutesGenerator) Execute() error

Execute creates the server routes file from the template

Jump to

Keyboard shortcuts

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