包装gin上下文数据获取
This commit is contained in:
@ -27,7 +27,7 @@ type contentType struct {
|
||||
//
|
||||
// Date : 00:35 2022/7/3
|
||||
func (ct *contentType) IsJson(ctx *gin.Context) bool {
|
||||
return strings.Contains(ct.Get(ctx), "json")
|
||||
return strings.Contains(WrapperHandle.GetContentType(ctx, "application/x-www-form-urlencoded"), "json")
|
||||
}
|
||||
|
||||
// IsFormURLEncoded 请求方式是否为 x-www-form-urlencoded
|
||||
@ -36,19 +36,5 @@ func (ct *contentType) IsJson(ctx *gin.Context) bool {
|
||||
//
|
||||
// Date : 00:36 2022/7/3
|
||||
func (ct *contentType) IsFormURLEncoded(ctx *gin.Context) bool {
|
||||
return strings.Contains(ct.Get(ctx), "x-www-form-urlencoded")
|
||||
}
|
||||
|
||||
// Get 获取请求类型
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 00:39 2022/7/3
|
||||
func (ct *contentType) Get(ctx *gin.Context) string {
|
||||
contentType := strings.ToLower(ctx.ContentType())
|
||||
if len(contentType) == 0 {
|
||||
// 请求不传type默认为 x-www-form-urlencoded
|
||||
contentType = "application/x-www-form-urlencoded"
|
||||
}
|
||||
return contentType
|
||||
return strings.Contains(WrapperHandle.GetContentType(ctx, "application/x-www-form-urlencoded"), "x-www-form-urlencoded")
|
||||
}
|
||||
|
Reference in New Issue
Block a user