|
|
@@ -5,14 +5,14 @@ import (
|
|
|
"git.sxidc.com/go-tools/utils/http_client"
|
|
|
)
|
|
|
|
|
|
-type UrlTransferFunc func(c *api.Context, url string, historyRequest []BuilderRequest, resultMap map[string]any) (string, error)
|
|
|
-type HeadersFormFunc func(c *api.Context, historyRequest []BuilderRequest, resultMap map[string]any) (map[string]string, error)
|
|
|
-type BodyFormFunc func(c *api.Context, historyRequest []BuilderRequest, resultMap map[string]any) (any, error)
|
|
|
-type QueryParamsFormFunc func(c *api.Context, historyRequest []BuilderRequest, resultMap map[string]any) (map[string]string, error)
|
|
|
-type PathParamsFormFunc func(c *api.Context, historyRequest []BuilderRequest, resultMap map[string]any) (map[string]string, error)
|
|
|
+type UrlTransferFunc func(c *api.Context, url string, historyRequests []BuilderRequest, resultMap map[string]any) (string, error)
|
|
|
+type HeadersFormFunc func(c *api.Context, historyRequests []BuilderRequest, resultMap map[string]any) (map[string]string, error)
|
|
|
+type BodyFormFunc func(c *api.Context, historyRequests []BuilderRequest, resultMap map[string]any) (any, error)
|
|
|
+type QueryParamsFormFunc func(c *api.Context, historyRequests []BuilderRequest, resultMap map[string]any) (map[string]string, error)
|
|
|
+type PathParamsFormFunc func(c *api.Context, historyRequests []BuilderRequest, resultMap map[string]any) (map[string]string, error)
|
|
|
|
|
|
func FormJsonBodyWithTenantIDAndUserIDFunc(tenantIDFieldName string, userIDFieldName string) BodyFormFunc {
|
|
|
- return func(c *api.Context, historyRequest []BuilderRequest, resultMap map[string]any) (any, error) {
|
|
|
+ return func(c *api.Context, historyRequests []BuilderRequest, resultMap map[string]any) (any, error) {
|
|
|
err := AddJsonBodyTenantIDAndUserID(c, tenantIDFieldName, userIDFieldName)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
@@ -28,7 +28,7 @@ func FormJsonBodyWithTenantIDAndUserIDFunc(tenantIDFieldName string, userIDField
|
|
|
}
|
|
|
|
|
|
func FormQueryParamsWithTenantIDAndUserIDFunc(tenantIDFieldName string, userIDFieldName string) QueryParamsFormFunc {
|
|
|
- return func(c *api.Context, historyRequest []BuilderRequest, resultMap map[string]any) (map[string]string, error) {
|
|
|
+ return func(c *api.Context, historyRequests []BuilderRequest, resultMap map[string]any) (map[string]string, error) {
|
|
|
err := AddQueryParamsTenantIDAndUserID(c, tenantIDFieldName, userIDFieldName)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
@@ -39,7 +39,7 @@ func FormQueryParamsWithTenantIDAndUserIDFunc(tenantIDFieldName string, userIDFi
|
|
|
}
|
|
|
|
|
|
type BuilderRequest interface {
|
|
|
- Request(c *api.Context, request *http_client.Request, historyRequest []BuilderRequest, resultMap map[string]any) (BuilderRequest, error)
|
|
|
+ Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, resultMap map[string]any) (BuilderRequest, error)
|
|
|
Response() *http_client.Response
|
|
|
}
|
|
|
|
|
|
@@ -100,18 +100,18 @@ func NewPostRequest(url string, opts ...PostRequestOption) *PostRequest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (req *PostRequest) Request(c *api.Context, request *http_client.Request, historyRequest []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
- url, err := req.options.urlTransferFunc(c, req.url, historyRequest, resultMap)
|
|
|
+func (req *PostRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
+ url, err := req.options.urlTransferFunc(c, req.url, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- headers, err := req.options.headersFormFunc(c, historyRequest, resultMap)
|
|
|
+ headers, err := req.options.headersFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- body, err := req.options.bodyFormFunc(c, historyRequest, resultMap)
|
|
|
+ body, err := req.options.bodyFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
@@ -204,23 +204,23 @@ func NewDeleteRequest(url string, opts ...DeleteRequestOption) *DeleteRequest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request, historyRequest []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
- url, err := req.options.urlTransferFunc(c, req.url, historyRequest, resultMap)
|
|
|
+func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
+ url, err := req.options.urlTransferFunc(c, req.url, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- headers, err := req.options.headersFormFunc(c, historyRequest, resultMap)
|
|
|
+ headers, err := req.options.headersFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- pathParams, err := req.options.pathParamsFormFunc(c, historyRequest, resultMap)
|
|
|
+ pathParams, err := req.options.pathParamsFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- queryParams, err := req.options.queryParamsFormFunc(c, historyRequest, resultMap)
|
|
|
+ queryParams, err := req.options.queryParamsFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
@@ -306,18 +306,18 @@ func NewPutRequest(url string, opts ...PutRequestOption) *PutRequest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (req *PutRequest) Request(c *api.Context, request *http_client.Request, historyRequest []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
- url, err := req.options.urlTransferFunc(c, req.url, historyRequest, resultMap)
|
|
|
+func (req *PutRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
+ url, err := req.options.urlTransferFunc(c, req.url, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- headers, err := req.options.headersFormFunc(c, historyRequest, resultMap)
|
|
|
+ headers, err := req.options.headersFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- body, err := req.options.bodyFormFunc(c, historyRequest, resultMap)
|
|
|
+ body, err := req.options.bodyFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
@@ -413,23 +413,23 @@ func NewGetRequest(url string, opts ...GetRequestOption) *GetRequest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (req *GetRequest) Request(c *api.Context, request *http_client.Request, historyRequest []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
- url, err := req.options.urlTransferFunc(c, req.url, historyRequest, resultMap)
|
|
|
+func (req *GetRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, resultMap map[string]any) (BuilderRequest, error) {
|
|
|
+ url, err := req.options.urlTransferFunc(c, req.url, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- headers, err := req.options.headersFormFunc(c, historyRequest, resultMap)
|
|
|
+ headers, err := req.options.headersFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- pathParams, err := req.options.pathParamsFormFunc(c, historyRequest, resultMap)
|
|
|
+ pathParams, err := req.options.pathParamsFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- queryParams, err := req.options.queryParamsFormFunc(c, historyRequest, resultMap)
|
|
|
+ queryParams, err := req.options.queryParamsFormFunc(c, historyRequests, resultMap)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|