package
1.0.4
Repository: https://github.com/obse4/gocommon.git
Documentation: pkg.go.dev

# README

goCommon httpserver

使用

import "github.com/obse4/goCommon/httpserver"

func main() {
    // 配置httpserver配置文件
    var httpServer = httpserver.HttpServerConfig{
		Port: "8080",
		Mode: "test",
	}
    // 创建httpserver服务
    httpserver.NewHttpServer(&httpserverConfig)

    // 注册swagger
    // 配合github.com/swaggo/swag使用
    // ! 注意引入swag init 后的init函数
    httpserver.RegisterSwagger(httpServer.Router)

    // 注册路由
    httpServer.Router.GET("health", func(ctx *gin.Context) {
		ctx.JSON(http.StatusOK, gin.H{
			"code":    200,
			"message": "ok",
			"data":    nil,
		})
	})

    // 初始化http服务监听
    httpserverConfig.Init()
}

# Packages

No description provided by the author

# Functions

跨域访问中间件.
No description provided by the author
接口错误返回函数.
接口返回.
gin IPRateLimit中间件.
No description provided by the author
新建IPRateLimiter r 单ip每秒通过次数 b buffer 大小,即单ip每秒最大通过次数.
Recover 确保该中间件处于最上层 可以防止程序挂掉.
注意引入docs下的init函数 配合github.com/swaggo/swag使用 go install github.com/swaggo/swag/cmd/swag@latest 生成swagger默认文件夹及根据注释写入内容 swag init 访问 http://127.0.0.1:8080/swagger/index.html#/ ! 注意引入swag init 后的init函数 import _ "your_project/docs".

# Structs

No description provided by the author
No description provided by the author