Skip to content

Commit

Permalink
refactor: 移除过时的 server.NewHttpWrapper 函数、server.Server.HttpServer 函数当…
Browse files Browse the repository at this point in the history
…需要使用 Gin 相关功能时不再需要通过 Gin 函数获取
  • Loading branch information
kercylan98 committed Dec 22, 2023
1 parent c4e2034 commit fde6d52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
6 changes: 3 additions & 3 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "github.com/gin-gonic/gin"
// - 默认使用 server.HttpContext 作为上下文,如果需要依赖其作为新的上下文,可以通过 NewHttpContext 创建
func NewHttpHandleWrapper[Context any](srv *Server, packer ContextPacker[Context]) *Http[Context] {
return &Http[Context]{
gin: srv.ginServer,
Engine: srv.ginServer,
HttpRouter: &HttpRouter[Context]{
srv: srv,
group: srv.ginServer,
Expand All @@ -18,10 +18,10 @@ func NewHttpHandleWrapper[Context any](srv *Server, packer ContextPacker[Context
// Http 基于 gin.Engine 包装的 http 服务器
type Http[Context any] struct {
srv *Server
gin *gin.Engine
*gin.Engine
*HttpRouter[Context]
}

func (slf *Http[Context]) Gin() *gin.Engine {
return slf.gin
return slf.Engine
}
12 changes: 0 additions & 12 deletions server/http_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ import (

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 函数的替代
func NewGinWrapper[CTX any](server *gin.Engine, pack func(ctx *gin.Context) CTX) *HttpWrapper[CTX] {
return &HttpWrapper[CTX]{
Expand Down

0 comments on commit fde6d52

Please sign in to comment.