@@ -7,47 +7,49 @@ import (
7
7
)
8
8
9
9
const (
10
- METHOD string = "method"
11
- URL string = "url"
12
- TOKEN_URL string = "tokenUrl"
13
- CSRF_URL string = "csrfUrl"
14
- CLIENT_ID string = "clientId"
15
- CLIENT_SECRET string = "clientSecret"
16
- REFRESH_TOKEN string = "refreshToken"
17
- HEADERS string = "headers"
18
- BODY string = "body"
19
- USER string = "user"
20
- PASSWORD string = "password"
21
- TIMEOUT string = "timeout"
22
- SUCCESS_RESPONSE_CODES string = "successResponseCodes"
23
- SUCCEED_ON_TIMEOUT string = "succeedOnTimeout"
24
- TRUSTED_CERTS string = "trustedCerts"
25
- CLIENT_CERT string = "clientCert"
26
- TRUST_ANY_CERT string = "trustAnyCert"
27
- AUTHORIZATION_HEADER string = "authorizationHeader"
10
+ METHOD string = "method"
11
+ URL string = "url"
12
+ TOKEN_URL string = "tokenUrl"
13
+ CSRF_URL string = "csrfUrl"
14
+ CLIENT_ID string = "clientId"
15
+ CLIENT_SECRET string = "clientSecret"
16
+ REFRESH_TOKEN string = "refreshToken"
17
+ RESPONSE_BODY_TRANSFORMER string = "responseBodyTransformer"
18
+ HEADERS string = "headers"
19
+ BODY string = "body"
20
+ USER string = "user"
21
+ PASSWORD string = "password"
22
+ TIMEOUT string = "timeout"
23
+ SUCCESS_RESPONSE_CODES string = "successResponseCodes"
24
+ SUCCEED_ON_TIMEOUT string = "succeedOnTimeout"
25
+ TRUSTED_CERTS string = "trustedCerts"
26
+ CLIENT_CERT string = "clientCert"
27
+ TRUST_ANY_CERT string = "trustAnyCert"
28
+ AUTHORIZATION_HEADER string = "authorizationHeader"
28
29
)
29
30
30
31
var (
31
32
defaultSuccessResponseCodes [1 ]string = [... ]string {"2xx" }
32
33
)
33
34
34
35
type HttpRequestParameters struct {
35
- method string
36
- url string
37
- tokenUrl string
38
- csrfUrl string
39
- clientId string
40
- clientSecret string
41
- refreshToken string
42
- headers map [string ]string
43
- body string
44
- user string
45
- password string
46
- timeout uint64
47
- successResponseCodes []string
48
- succeedOnTimeout bool
49
- certAuthentication * tls.CertificateAuthentication
50
- authorizationHeader string
36
+ method string
37
+ url string
38
+ tokenUrl string
39
+ csrfUrl string
40
+ clientId string
41
+ clientSecret string
42
+ refreshToken string
43
+ responseBodyTransformer string
44
+ headers map [string ]string
45
+ body string
46
+ user string
47
+ password string
48
+ timeout uint64
49
+ successResponseCodes []string
50
+ succeedOnTimeout bool
51
+ certAuthentication * tls.CertificateAuthentication
52
+ authorizationHeader string
51
53
}
52
54
53
55
func NewHttpRequestParametersFromContext (ctx executors.ExecutorContext ) * HttpRequestParameters {
@@ -59,6 +61,7 @@ func NewHttpRequestParametersFromContext(ctx executors.ExecutorContext) *HttpReq
59
61
withClientIdFromContext (& ctx ),
60
62
withClientSecretFromContext (& ctx ),
61
63
withRefreshTokenFromContext (& ctx ),
64
+ withResponseBodyTransformerFromContext (& ctx ),
62
65
withHeadersFromContext (& ctx ),
63
66
withBodyFromContext (& ctx ),
64
67
withUserFromContext (& ctx ),
@@ -318,6 +321,15 @@ func withRefreshTokenFromContext(ctx *executors.ExecutorContext) functional.Opti
318
321
}
319
322
}
320
323
324
+ func withResponseBodyTransformerFromContext (ctx * executors.ExecutorContext ) functional.OptionWithError [HttpRequestParameters ] {
325
+ return func (hrp * HttpRequestParameters ) error {
326
+ t := ctx .GetString (RESPONSE_BODY_TRANSFORMER )
327
+
328
+ hrp .responseBodyTransformer = t
329
+ return nil
330
+ }
331
+ }
332
+
321
333
func withHeadersFromContext (ctx * executors.ExecutorContext ) functional.OptionWithError [HttpRequestParameters ] {
322
334
return func (hrp * HttpRequestParameters ) error {
323
335
h , err := ctx .GetMap (HEADERS )
0 commit comments