library

package
v0.0.0-...-1f163c1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

Cross-Origin Resource Sharing

func CORSOfficial

func CORSOfficial() gin.HandlerFunc

未设置

func ReadYamlConfig

func ReadYamlConfig(bean interface{}, filename string) error

GetYamlConfig 支持将配置的yaml文件加载至与之对应的结构体中

func WriteYamlConfig

func WriteYamlConfig(bean interface{}, filename string) error

WriteYamlConfig 将结构体写入到配置文件

Types

type Router

type Router struct {
	Method  string
	URI     string
	Handler gin.HandlerFunc
}

Router 是一个服务的路由属性

func NewRouter

func NewRouter(m string, u string, h gin.HandlerFunc) Router

NewRouter 创建一个 Router

type RouterGroup

type RouterGroup struct {
	Group map[string][]Router
}

RouterGroup 是一组路由

type Service

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

Service 是web服务引擎

func NewService

func NewService(conf ServiceConfig) *Service

NewService 创建一个服务

func (*Service) RegisterRouterGroups

func (s *Service) RegisterRouterGroups(groups map[string][]Router)

RegisterRouterGroups 注册一组路由,这里一组路由是有相同中间件或URI组

func (*Service) RegisterRouters

func (s *Service) RegisterRouters(routers []Router)

RegisterRouters 注册路由列表

func (*Service) Run

func (s *Service) Run() error

启动服务

func (*Service) UseMidwares

func (s *Service) UseMidwares(midwares ...gin.HandlerFunc)

RegisterMidwares 注册 Routers

type ServiceConfig

type ServiceConfig struct {
	IPAddr string // ip:port
	Debug  bool   // 是否开启Debug
}

ServiceConfig 是web服务的配置信息

Jump to

Keyboard shortcuts

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