route

package
v0.0.0-...-12a504c Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistributeRouters

func DistributeRouters(r *gin.RouterGroup, routes []Route, resourcer Resourcer)

Types

type Resource

type Resource struct {
	DB          *gorm.DB            `gatecloud:"initparam"`
	Validator   *validator.Validate `gatecloud:"initparam"`
	RedisClient *redis.Client       `gatecloud:"initparam"`
}

Resource representing the shared resource

func (*Resource) Resources

func (r *Resource) Resources() ([]reflect.Value, error)

Resources returns all resources that tag as initparam

type Resourcer

type Resourcer interface {
	Resources() ([]reflect.Value, error)
}

Resourcer is a common interface to allow to add custom resources

type Route

type Route struct {
	Name       string
	Controller reflect.Type
	Model      interface{}
}

Route stores a single route entity's information

func (Route) Register

func (r Route) Register(action string, resourcer Resourcer) func(ctx *gin.Context)

Register registers the API to route

type Router

type Router interface {
	Register(action string, sr *Resource) func(ctx *gin.Context)
}

Router is a common interface to proceed the router's operation

Jump to

Keyboard shortcuts

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