From 3298adb55a120e49d0029c5282773a344bb1561e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 2 Jan 2024 15:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=B7=E6=B1=82=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=9A=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- request/wrapper.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/request/wrapper.go b/request/wrapper.go index b2e4f0d..d031144 100644 --- a/request/wrapper.go +++ b/request/wrapper.go @@ -61,6 +61,18 @@ func (wh *wrapperHandle) GetUri(ctx *gin.Context, defaultVal string) string { return defaultVal } +// GetMethod 获取请求方法 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:19 2024/1/2 +func (wh *wrapperHandle) GetMethod(ctx *gin.Context) string { + if nil != ctx && nil != ctx.Request { + return ctx.Request.Method + } + return "" +} + // GetContentType 获取请求方式 // // Author : go_developer@163.com<白茶清欢> @@ -74,10 +86,11 @@ func (wh *wrapperHandle) GetContentType(ctx *gin.Context, defaultVal string) str return wrapper.TernaryOperator.String(len(contentType) > 0, wrapper.String(contentType), wrapper.String(defaultVal)).Value() } +// GetResponseBody 获取响应body +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:18 2024/1/2 func (wh *wrapperHandle) GetResponseBody(ctx *gin.Context, defaultVal string) string { - if nil == ctx { - return defaultVal - } - contentType := strings.ToLower(ctx.ContentType()) - return wrapper.TernaryOperator.String(len(contentType) > 0, wrapper.String(contentType), wrapper.String(defaultVal)).Value() + return "" }