gins

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 16 Imported by: 0

README

gins

Documentation

Index

Constants

View Source
const VERSION = "1.3.2"

VERSION 版本号

Variables

This section is empty.

Functions

func AddInit

func AddInit(fn func(gs *Server))

AddInit 安全添加初始化方法

func GetAPIResponse

func GetAPIResponse(ctx *gin.Context) (res *apiResponse)

GetAPIResponse 获取 API 响应对象

func GetValidate added in v1.2.0

func GetValidate() *validator.Validate

GetValidate 获取 gin 内部的 Validate 对象

func GetWebResponse added in v1.3.0

func GetWebResponse(ctx *gin.Context) (res *webResponse)

GetWebResponse 获取 Web 响应对象

func Init

func Init(conf *Config)

Init 初始化实例,一般直接调用 Run 即可,内置了 Init 的调用

func Run

func Run(conf *Config)

Run 启动

func Stop

func Stop()

Stop 停止

Types

type Config

type Config struct {
	Name          string // 服务名称,必填
	Version       string // 服务版本,必填
	Host          string // 域名主机
	IP            string // 运行地址,必填
	BroadcastIP   string // 广播的运行地址,默认为:IP
	Port          int    // 运行端口,必填
	BroadcastPort int    // 广播的运行端口,默认为:Port
	Timeout       int    // 优雅退出时的超时机制,默认:30秒
	Debug         bool   // 是否开启调试
	Pprof         bool   // 是否监控性能

	LogLevel string // logger 日志级别,支持:trace、debug、info、warn、error、fatal、panic,默认:info

	IsDisableSignal    bool // 是否关闭 signal 信号监听退出,默认:false,设置为 true 时,需主动调用 gins.Stop() 来触发优雅退出
	IsEnableKeepAlives bool // 是否开启 KeepAlive ,默认:false

	On500 gin.RecoveryFunc // 自定义 500 处理,相当于 panic 的 recover 处理
	On404 gin.HandlerFunc  // 自定义 404 处理
	// contains filtered or unexported fields
}

Config 服务器配置

func (*Config) Addr

func (conf *Config) Addr() string

Addr 运行地址

func (*Config) BroadcastAddr

func (conf *Config) BroadcastAddr() string

BroadcastAddr 广播的运行地址

func (*Config) Init

func (conf *Config) Init() (err error)

Init 初始化配置

type IResponse

type IResponse interface {
	// contains filtered or unexported methods
}

type Server

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

func Instance

func Instance() *Server

Instance 实例

func New

func New(conf *Config) (gs *Server, err error)

New 新服务

func (*Server) AddTemplate added in v1.3.0

func (gs *Server) AddTemplate(name string, body []byte) (err error)

AddTemplate 添加模板

func (*Server) Engine

func (gs *Server) Engine() *gin.Engine

Engine gin engine

func (*Server) Run

func (gs *Server) Run()

Run 启动

func (*Server) Stop

func (gs *Server) Stop()

Stop 停止

Directories

Path Synopsis
db
model
Code generated by github.com/zaaksam/gins/extend/orm/xmodel.
Code generated by github.com/zaaksam/gins/extend/orm/xmodel.
extend
orm

Jump to

Keyboard shortcuts

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