refactor: 移除过时的 server.NewHttpWrapper 函数、server.Server.HttpServer 函数当需要使用 Gin 相关功能时不再需要通过 Gin 函数获取
This commit is contained in:
parent
c4e2034bef
commit
fde6d52c60
|
@ -6,7 +6,7 @@ import "github.com/gin-gonic/gin"
|
||||||
// - 默认使用 server.HttpContext 作为上下文,如果需要依赖其作为新的上下文,可以通过 NewHttpContext 创建
|
// - 默认使用 server.HttpContext 作为上下文,如果需要依赖其作为新的上下文,可以通过 NewHttpContext 创建
|
||||||
func NewHttpHandleWrapper[Context any](srv *Server, packer ContextPacker[Context]) *Http[Context] {
|
func NewHttpHandleWrapper[Context any](srv *Server, packer ContextPacker[Context]) *Http[Context] {
|
||||||
return &Http[Context]{
|
return &Http[Context]{
|
||||||
gin: srv.ginServer,
|
Engine: srv.ginServer,
|
||||||
HttpRouter: &HttpRouter[Context]{
|
HttpRouter: &HttpRouter[Context]{
|
||||||
srv: srv,
|
srv: srv,
|
||||||
group: srv.ginServer,
|
group: srv.ginServer,
|
||||||
|
@ -18,10 +18,10 @@ func NewHttpHandleWrapper[Context any](srv *Server, packer ContextPacker[Context
|
||||||
// Http 基于 gin.Engine 包装的 http 服务器
|
// Http 基于 gin.Engine 包装的 http 服务器
|
||||||
type Http[Context any] struct {
|
type Http[Context any] struct {
|
||||||
srv *Server
|
srv *Server
|
||||||
gin *gin.Engine
|
*gin.Engine
|
||||||
*HttpRouter[Context]
|
*HttpRouter[Context]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *Http[Context]) Gin() *gin.Engine {
|
func (slf *Http[Context]) Gin() *gin.Engine {
|
||||||
return slf.gin
|
return slf.Engine
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,6 @@ import (
|
||||||
|
|
||||||
type HttpWrapperHandleFunc[CTX any] func(ctx CTX)
|
type HttpWrapperHandleFunc[CTX any] func(ctx CTX)
|
||||||
|
|
||||||
// NewHttpWrapper 创建 http 包装器
|
|
||||||
//
|
|
||||||
// Deprecated: 从 Minotaur 0.0.29 开始,由于该函数基于 *Server.HttpRouter 函数设计,已弃用。
|
|
||||||
// 如果需要单纯的对 *gin.Engine 进行包装,可以使用 NewGinWrapper 函数进行包装。该函数已不在建议对 server.Server 使用。
|
|
||||||
// 如果需要对 Server.HttpServer 进行包装,可以使用 NewHttpHandleWrapper 函数进行包装。
|
|
||||||
func NewHttpWrapper[CTX any](server *Server, pack func(ctx *gin.Context) CTX) *HttpWrapper[CTX] {
|
|
||||||
return &HttpWrapper[CTX]{
|
|
||||||
server: server.ginServer,
|
|
||||||
packHandle: pack,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewGinWrapper 创建 gin 包装器,用于对 NewHttpWrapper 函数的替代
|
// NewGinWrapper 创建 gin 包装器,用于对 NewHttpWrapper 函数的替代
|
||||||
func NewGinWrapper[CTX any](server *gin.Engine, pack func(ctx *gin.Context) CTX) *HttpWrapper[CTX] {
|
func NewGinWrapper[CTX any](server *gin.Engine, pack func(ctx *gin.Context) CTX) *HttpWrapper[CTX] {
|
||||||
return &HttpWrapper[CTX]{
|
return &HttpWrapper[CTX]{
|
||||||
|
|
Loading…
Reference in New Issue