config

package
v0.0.0-...-7f855fe Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationProperties

type ApplicationProperties struct {
	DSN               string //数据库连接串
	MongoURL          string //mongodb 连接串
	MongoDatabase     string //mongodb 数据库
	RedisURL          string //redis 连接串
	BindAdreess       string //restful url
	FileBaseDir       string //文件存储基础位置
	FileMaxSize       int    //文件最大大小
	OAuthClientID     string //github OAuth 的client ID
	OAuthClientSecret string //github OAuth 的client secret
}

ApplicationProperties 全局配置字符串

type CORSRouterDecorator

type CORSRouterDecorator struct {
	R *mux.Router
}

CORSRouterDecorator applies CORS headers to a mux.Router

func (*CORSRouterDecorator) ServeHTTP

func (c *CORSRouterDecorator) ServeHTTP(rw http.ResponseWriter, req *http.Request)

使用装饰者模式解决CORS问题 ServeHTTP wraps the HTTP server enabling CORS headers. For more info about CORS, visit https://www.w3.org/TR/cors/

type Configs

type Configs struct {
	ApplicationProperties
	// contains filtered or unexported fields
}

Configs 所有配置

func GetConfigs

func GetConfigs() *Configs

GetConfigs 注册所有配置

func (*Configs) LoadConfigs

func (c *Configs) LoadConfigs()

LoadConfigs 批量配置所有

func (*Configs) LogBanner

func (c *Configs) LogBanner()

LogBanner 打印banner

func (*Configs) RegisterService

func (c *Configs) RegisterService(service Service)

RegisterService 注册配置

func (*Configs) RegisterServices

func (c *Configs) RegisterServices()

RegisterServices 注册所有服务 扩展的服务需要写在这

func (*Configs) ShutdownAll

func (c *Configs) ShutdownAll()

ShutdownAll 结束所有服务

type Connection

type Connection struct {
	DB *sqlx.DB // sqlx DB

	MongoDB *mongo.Database // mongo DB
	Redis   *redis.Client   // redis DB
	// contains filtered or unexported fields
}

Connection 数据库连接

func GetConnection

func GetConnection() *Connection

GetConnection 获取连接

func (*Connection) Config

func (c *Connection) Config(configs *Configs)

Config 实现配置接口

func (*Connection) Shutdown

func (c *Connection) Shutdown()

Shutdown 结束

type HTTPRequestHandler

type HTTPRequestHandler interface {
	GetRoutes() []*Route
}

HTTPRequestHandler http请求的handler

type Route

type Route struct {
	Method          string               //方法类型
	Path            string               //路由路径
	Handler         http.HandlerFunc     //处理器
	MiddlewareFuncs []mux.MiddlewareFunc //中间件
}

Route 路由 wrapper

type Router

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

Router 小小路由封装

func GetDefaultRouter

func GetDefaultRouter() *Router

GetDefaultRouter 获取路由

func NewRouter

func NewRouter() *Router

NewRouter 新建router

func (*Router) AddHTTPRequestHanlder

func (r *Router) AddHTTPRequestHanlder(hanlder HTTPRequestHandler) *Router

AddHTTPRequestHanlder 添加

func (*Router) Config

func (r *Router) Config(configs *Configs)

Config 路由配置

func (*Router) Shutdown

func (r *Router) Shutdown()

Shutdown 实现Service接口

type Service

type Service interface {
	Config(c *Configs)
	Shutdown()
}

Service 配置接口 实现该接口 在程序启动后会调用Service()方法

Jump to

Keyboard shortcuts

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