app

package
v1.0.12 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api added in v1.0.9

type Api struct {
	// 路由,格式为: <Method> <Route>
	//
	// 例如:
	//  GET /api/user
	//  post /api/user/new
	Route   string `yaml:"route"`
	Handler string `yaml:"handler"` // API处理器名称列表
}

type ApiGroup added in v1.0.9

type ApiGroup struct {
	Prefix      string     `yaml:"prefix"`      // API组的路由前缀
	MiddleWares []string   `yaml:"middleWares"` // API组的中间件名称列表
	ApiGroup    []ApiGroup `yaml:"groups"`      // 路由配置
	Apis        []Api      `yaml:"apis"`        // API组的API列表
}

type App

type App struct {
	Config *Config
}

func NewApp

func NewApp() *App

NewApp 初始化一个App

func (*App) LoadFromYamlContent added in v1.0.9

func (a *App) LoadFromYamlContent(yaml string) error

LoadFromYamlContent 从给定的yaml内容加载配置

func (*App) LoadFromYamlFile added in v1.0.9

func (a *App) LoadFromYamlFile(path string) error

LoadFromYamlFile 从指定路径的yaml文件加载配置

type CaptchaConfig

type CaptchaConfig struct {
	Width           int    `yaml:"width"`      // 图片宽度
	Height          int    `yaml:"height"`     // 图片高度
	Source          string `yaml:"seed"`       // 种子字符
	Length          int    `yaml:"length"`     // 验证码字符数
	NoiseCount      int    `yaml:"noiseCount"` // 干扰字符数
	FontName        string `yaml:"fontName"`   // 字体名称
	BackgroundColor string `yaml:"background"` // 背景色
	Store           string `yaml:"store"`      // 验证码保存:memory|redis
}

CaptchaConfig requires github.com/hetianyi/base64Captcha

type Config

type Config struct {
	Server        Server        `yaml:"server"`
	RedisConfig   RedisConfig   `yaml:"redis"`
	MysqlConfig   MysqlConfig   `yaml:"mysql"`
	CaptchaConfig CaptchaConfig `yaml:"captcha"`
}

Config 为全部配置 requires gopkg.in/yaml.v2

type MysqlConfig

type MysqlConfig struct {
	// mysql连接,格式:
	//
	//  <username>:<password>@tcp(<host>:<port>)/<db>?charset=utf8&parseTime=True&loc=Local
	Conn string `yaml:"conn"`
	// 最大空闲连接
	MaxIdleConns int `yaml:"maxIdleConns"`
	// 最大连接数
	MaxOpenConns int `yaml:"maxOpenConns"`
	// 每个连接最长声明周期
	ConnMaxLifetime int `yaml:"connMaxLifetime"`
}

MysqlConfig 为mysql的配置

requires gorm.io/driver/mysql and gorm.io/gorm

type RedisConfig

type RedisConfig struct {
	Host      string `yaml:"host"` // 服务器地址
	Port      int    `yaml:"port"` // 服务端口
	Pass      string `yaml:"pass"` // 密码
	DefaultDB int    `yaml:"db"`   // 默认数据库
}

RedisConfig 为redis的配置

requires github.com/go-redis/redis

type Server

type Server struct {
	Host         string     `yaml:"host"`         // HTTP服务监听地址
	Port         int        `yaml:"port"`         // HTTP服务监听端口
	GinMode      string     `yaml:"mode"`         // 服务启动模式:debug|release
	UseGinLogger bool       `yaml:"useGinLogger"` // 是否开启gin的默认Logger
	MiddleWares  []string   `yaml:"middleWares"`  // 中间件名称列表
	Validators   []string   `yaml:"validators"`   // 校验器名称列表
	ApiGroup     []ApiGroup `yaml:"groups"`       // 路由配置
}

Server 为http服务器的配置

Jump to

Keyboard shortcuts

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