Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how request modifiers behave for slices and maps. #225

Merged
merged 18 commits into from
Aug 2, 2023

Conversation

averche
Copy link
Collaborator

@averche averche commented Jul 30, 2023

Description

For any slice value (request/response callbacks + MFA credentials), the request-level modifiers will be appended to the global client-level ones.

For any map value (custom headers), the request-level modifies will be be appended overwriting the existing keys (maps.Copy semantics).

This seems to be a more intuitive approach but I'm open to suggestions.

Example

For the code below:

client.SetRequestCallbacks(func(req *http.Request) {
	log.Println("client level")
})

resp, err := client.Secrets.KvV2Read(
	ctx,
	"my-secret",
	vault.WithRequestCallbacks(func(req *http.Request) {
		log.Println("request level")
	}),
)

The current output is:

request level

The out utput after this PR:

client level
request level

How has this been tested?

Added a test specific to this.

@averche averche requested a review from a team July 30, 2023 21:07
Base automatically changed from refactor-merge to main July 31, 2023 19:35
request_modifiers.go Outdated Show resolved Hide resolved
@averche averche merged commit 27cd603 into main Aug 2, 2023
4 checks passed
@averche averche deleted the append-request-modifiers1 branch August 2, 2023 21:19
@averche averche mentioned this pull request Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants