From 325efde765f6256816728b6f6fff54d59e2508e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 25 Nov 2024 14:43:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=B1=BB=E5=9E=8B=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=E5=80=BC=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- enums/data_location.go | 38 ++++++++++++++++++++++++++++++++++++++ request.go | 39 +++++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 enums/data_location.go diff --git a/enums/data_location.go b/enums/data_location.go new file mode 100644 index 0000000..706fd5a --- /dev/null +++ b/enums/data_location.go @@ -0,0 +1,38 @@ +// Package enums ... +// +// Description : enums ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2024-11-25 14:39 +package enums + +// RequestDataLocation 请求数据所在位置 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:40 2024/11/25 +type RequestDataLocation string + +func (rdl RequestDataLocation) String() string { + return string(rdl) +} + +func (rdl RequestDataLocation) MarshalJSON() ([]byte, error) { + return []byte(rdl.String()), nil +} + +// ResponseDataLocation 响应数据所在位置 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:41 2024/11/25 +type ResponseDataLocation string + +func (rdl ResponseDataLocation) String() string { + return string(rdl) +} + +func (rdl ResponseDataLocation) MarshalJSON() ([]byte, error) { + return []byte(rdl.String()), nil +} diff --git a/request.go b/request.go index 9fcba37..588a48a 100644 --- a/request.go +++ b/request.go @@ -7,30 +7,37 @@ // Date : 2024-04-22 11:04 package consts +import "git.zhangdeman.cn/zhangdeman/consts/enums" + const ( - RequestDataLocationHeader = "HEADER" // header - RequestDataLocationCookie = "COOKIE" // cookie - RequestDataLocationBody = "BODY" // body - RequestDataLocationQuery = "QUERY" // query - RequestDataLocationUriPath = "URI_PATH" // uri路由一部分 - RequestDataLocationStatic = "STATIC" // 静态配置的参数 - RequestDataLocationCustomConfig = "CUSTOM_CONFIG" // 针对接口的一些自定义配置规则 + RequestDataLocationHeader enums.RequestDataLocation = "HEADER" // header + RequestDataLocationCookie enums.RequestDataLocation = "COOKIE" // cookie + RequestDataLocationBody enums.RequestDataLocation = "BODY" // body + RequestDataLocationQuery enums.RequestDataLocation = "QUERY" // query + RequestDataLocationUriPath enums.RequestDataLocation = "URI_PATH" // uri路由一部分 + RequestDataLocationStatic enums.RequestDataLocation = "STATIC" // 静态配置的参数 + RequestDataLocationCustomConfig enums.RequestDataLocation = "CUSTOM_CONFIG" // 针对接口的一些自定义配置规则 ) const ( - ResponseDataLocationHeader = "HEADER" // header - ResponseDataLocationCookie = "COOKIE" // cookie - ResponseDataLocationBody = "BODY" // body - ResponseDataLocationExtension = "EXTENSION" // 扩展信息 + ResponseDataLocationHeader enums.ResponseDataLocation = "HEADER" // header + ResponseDataLocationCookie enums.ResponseDataLocation = "COOKIE" // cookie + ResponseDataLocationBody enums.ResponseDataLocation = "BODY" // body + ResponseDataLocationExtension enums.ResponseDataLocation = "EXTENSION" // 扩展信息 ) -type DataLocationDesc struct { - Value string `json:"value"` // 数据位置 - Description string `json:"description"` // 数据位置描述 +type RequestDataLocationDesc struct { + Value enums.RequestDataLocation `json:"value"` // 数据位置 + Description string `json:"description"` // 数据位置描述 +} + +type ResponseDataLocationDesc struct { + Value enums.ResponseDataLocation `json:"value"` // 数据位置 + Description string `json:"description"` // 数据位置描述 } var ( - RequestDataLocationList = []DataLocationDesc{ + RequestDataLocationList = []RequestDataLocationDesc{ {Value: RequestDataLocationHeader, Description: "请求header"}, {Value: RequestDataLocationCookie, Description: "请求cookie"}, {Value: RequestDataLocationBody, Description: "请求body"}, @@ -39,7 +46,7 @@ var ( {Value: RequestDataLocationStatic, Description: "静态参数配置"}, {Value: RequestDataLocationCustomConfig, Description: "自定义接口处理规则"}, } - ResponseDataLocationList = []DataLocationDesc{ + ResponseDataLocationList = []ResponseDataLocationDesc{ {Value: ResponseDataLocationHeader, Description: "响应header"}, {Value: ResponseDataLocationCookie, Description: "响应cookie"}, {Value: ResponseDataLocationBody, Description: "响应body"},