|
|
@@ -6,31 +6,31 @@ import (
|
|
|
"net/http"
|
|
|
)
|
|
|
|
|
|
-type FormHeadersFunc func(c *api.Context) (map[string]string, error)
|
|
|
-type FormBodyFunc func(c *api.Context) (any, error)
|
|
|
-type FormQueryParamsFunc func(c *api.Context) (map[string]string, error)
|
|
|
-type FormPathParamsFunc func(c *api.Context) (map[string]string, error)
|
|
|
+type FormHeadersFunc func(c *api.Context, historyRequests []BuilderRequest, customResultMap map[string]any) (map[string]string, error)
|
|
|
+type FormBodyFunc func(c *api.Context, historyRequests []BuilderRequest, customResultMap map[string]any) (any, error)
|
|
|
+type FormQueryParamsFunc func(c *api.Context, historyRequests []BuilderRequest, customResultMap map[string]any) (map[string]string, error)
|
|
|
+type FormPathParamsFunc func(c *api.Context, historyRequests []BuilderRequest, customResultMap map[string]any) (map[string]string, error)
|
|
|
|
|
|
-func DefaultFormHeadersFunc(c *api.Context) (map[string]string, error) {
|
|
|
+func DefaultFormHeadersFunc(c *api.Context, _ []BuilderRequest, _ map[string]any) (map[string]string, error) {
|
|
|
return c.GetHeaders(), nil
|
|
|
}
|
|
|
|
|
|
-func DefaultFormBodyFunc(c *api.Context) (any, error) {
|
|
|
+func DefaultFormBodyFunc(c *api.Context, _ []BuilderRequest, _ map[string]any) (any, error) {
|
|
|
return c.ReadBody()
|
|
|
}
|
|
|
|
|
|
-func DefaultFormQueryParamsFunc(c *api.Context) (map[string]string, error) {
|
|
|
+func DefaultFormQueryParamsFunc(c *api.Context, _ []BuilderRequest, _ map[string]any) (map[string]string, error) {
|
|
|
return c.GetAllQueryParams(), nil
|
|
|
}
|
|
|
|
|
|
-func DefaultFormPathParamsFunc(c *api.Context) (map[string]string, error) {
|
|
|
+func DefaultFormPathParamsFunc(c *api.Context, _ []BuilderRequest, _ map[string]any) (map[string]string, error) {
|
|
|
return c.GetAllPathParams(), nil
|
|
|
}
|
|
|
|
|
|
type BuilderRequest interface {
|
|
|
HttpMethod() string
|
|
|
RequestUrl() string
|
|
|
- Request(c *api.Context, request *http_client.Request) error
|
|
|
+ Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, customResultMap map[string]any) error
|
|
|
Response() *http_client.Response
|
|
|
}
|
|
|
|
|
|
@@ -50,7 +50,7 @@ func (req *PostRequest) RequestUrl() string {
|
|
|
return req.Url
|
|
|
}
|
|
|
|
|
|
-func (req *PostRequest) Request(c *api.Context, request *http_client.Request) error {
|
|
|
+func (req *PostRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, customResultMap map[string]any) error {
|
|
|
if req.Headers == nil {
|
|
|
req.Headers = DefaultFormHeadersFunc
|
|
|
}
|
|
|
@@ -59,12 +59,12 @@ func (req *PostRequest) Request(c *api.Context, request *http_client.Request) er
|
|
|
req.Body = DefaultFormBodyFunc
|
|
|
}
|
|
|
|
|
|
- headers, err := req.Headers(c)
|
|
|
+ headers, err := req.Headers(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- body, err := req.Body(c)
|
|
|
+ body, err := req.Body(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -101,7 +101,7 @@ func (req *DeleteRequest) RequestUrl() string {
|
|
|
return req.Url
|
|
|
}
|
|
|
|
|
|
-func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request) error {
|
|
|
+func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, customResultMap map[string]any) error {
|
|
|
if req.Headers == nil {
|
|
|
req.Headers = DefaultFormHeadersFunc
|
|
|
}
|
|
|
@@ -114,17 +114,17 @@ func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request)
|
|
|
req.PathParams = DefaultFormPathParamsFunc
|
|
|
}
|
|
|
|
|
|
- headers, err := req.Headers(c)
|
|
|
+ headers, err := req.Headers(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- queryParams, err := req.QueryParams(c)
|
|
|
+ queryParams, err := req.QueryParams(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- pathParams, err := req.PathParams(c)
|
|
|
+ pathParams, err := req.PathParams(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -162,7 +162,7 @@ func (req *PutRequest) RequestUrl() string {
|
|
|
return req.Url
|
|
|
}
|
|
|
|
|
|
-func (req *PutRequest) Request(c *api.Context, request *http_client.Request) error {
|
|
|
+func (req *PutRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, customResultMap map[string]any) error {
|
|
|
if req.Headers == nil {
|
|
|
req.Headers = DefaultFormHeadersFunc
|
|
|
}
|
|
|
@@ -171,12 +171,12 @@ func (req *PutRequest) Request(c *api.Context, request *http_client.Request) err
|
|
|
req.Body = DefaultFormBodyFunc
|
|
|
}
|
|
|
|
|
|
- headers, err := req.Headers(c)
|
|
|
+ headers, err := req.Headers(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- body, err := req.Body(c)
|
|
|
+ body, err := req.Body(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -213,7 +213,7 @@ func (req *GetRequest) RequestUrl() string {
|
|
|
return req.Url
|
|
|
}
|
|
|
|
|
|
-func (req *GetRequest) Request(c *api.Context, request *http_client.Request) error {
|
|
|
+func (req *GetRequest) Request(c *api.Context, request *http_client.Request, historyRequests []BuilderRequest, customResultMap map[string]any) error {
|
|
|
if req.Headers == nil {
|
|
|
req.Headers = DefaultFormHeadersFunc
|
|
|
}
|
|
|
@@ -226,17 +226,17 @@ func (req *GetRequest) Request(c *api.Context, request *http_client.Request) err
|
|
|
req.PathParams = DefaultFormPathParamsFunc
|
|
|
}
|
|
|
|
|
|
- headers, err := req.Headers(c)
|
|
|
+ headers, err := req.Headers(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- queryParams, err := req.QueryParams(c)
|
|
|
+ queryParams, err := req.QueryParams(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- pathParams, err := req.PathParams(c)
|
|
|
+ pathParams, err := req.PathParams(c, historyRequests, customResultMap)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|