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 "" }