响应解析基于接口实现

This commit is contained in:
2025-05-07 15:48:36 +08:00
parent 088670c7d4
commit 741c9c8ea0
5 changed files with 193 additions and 94 deletions

View File

@ -0,0 +1,30 @@
// Package abstract ...
//
// Description : abstract ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2025-05-07 14:28
package abstract
import (
"git.zhangdeman.cn/zhangdeman/network/httpclient/define"
)
// IResponseParser 响应结果的序列化解析器
type IResponseParser interface {
// Unmarshal 反序列化解析
Unmarshal(byteData []byte, receiver any) error
// MarshalForByte 序列化
MarshalForByte(input any) ([]byte, error)
}
// IResponse 响应解析
type IResponse interface {
// Parse 解析响应
Parse(reqConfig *define.Request, response *define.Response)
// BusinessSuccess 业务状态码是否成功
BusinessSuccess(reqCfg *define.Request, response *define.Response) bool
// HttpSuccess http状态码是否成功
HttpSuccess(reqCfg *define.Request, response *define.Response) bool
}