From 6b2a753e67f3605db2cdeb0760fbf30db937037b Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 6 Nov 2023 20:26:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20server=20=E5=8C=85=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=88=B0=20HTTP=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E7=9A=84=20Gin=20=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/http.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/http.go b/server/http.go index 38ba4ee..7ef78e0 100644 --- a/server/http.go +++ b/server/http.go @@ -1,9 +1,12 @@ package server +import "github.com/gin-gonic/gin" + // NewHttpHandleWrapper 创建一个新的 http 处理程序包装器 // - 默认使用 server.HttpContext 作为上下文,如果需要依赖其作为新的上下文,可以通过 NewHttpContext 创建 func NewHttpHandleWrapper[Context any](srv *Server, packer ContextPacker[Context]) *Http[Context] { return &Http[Context]{ + gin: srv.ginServer, HttpRouter: &HttpRouter[Context]{ srv: srv, group: srv.ginServer, @@ -15,5 +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 *HttpRouter[Context] } + +func (slf *Http[Context]) Gin() *gin.Engine { + return slf.gin +}