涉及请求体解析适配器接口约束
This commit is contained in:
26
request/abstract/parse_body.go
Normal file
26
request/abstract/parse_body.go
Normal file
@ -0,0 +1,26 @@
|
||||
// Package abstract ...
|
||||
//
|
||||
// Description : abstract ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2024-10-22 16:38
|
||||
package abstract
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RequestBodyParseAdaptor 解析请求body的接口适配器约束
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:39 2024/10/22
|
||||
type RequestBodyParseAdaptor interface {
|
||||
// Parse 解析Body数据,解析结果会反序列化至 receiver , 同时, 会以 map 结构返回
|
||||
Parse(ctx *gin.Context, receiver any) ([]byte, error)
|
||||
// Unmarshal 自定义反序列化的方法, 为 nil 则使用内置的序列化方式
|
||||
Unmarshal() func(sourceData []byte, receiver any) error
|
||||
// ContentType 当前适配器用与解析何种type
|
||||
ContentType() string
|
||||
}
|
Reference in New Issue
Block a user