Skip to content

invoke: add --header flag for custom HTTP headers - #1698

Open
magic-peach wants to merge 1 commit into
dapr:masterfrom
magic-peach:feat/invoke-custom-headers
Open

magic-peach wants to merge 1 commit into
dapr:masterfrom
magic-peach:feat/invoke-custom-headers

Conversation

@magic-peach

Copy link
Copy Markdown

Description

dapr invoke had no way to send custom HTTP headers to the target app; only Content-Type: application/json was ever set. This PR adds a repeatable --header/-H flag in Key=Value form, parsed into an http.Header and threaded through Standalone.Invoke() down to the outgoing request. A prior attempt at this (#1287) stalled on an unrelated dependency bump requested in review, not on the feature itself, so this keeps the same flag shape and scopes the change to invoke plumbing only.

Issue reference

Please reference the issue this PR will close: #1286

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Notes:

  • Compiles: verified with go build ..
  • Tests: added TestInvokeWithHeaders in pkg/standalone/invoke_test.go, asserting a header passed to Invoke() reaches the outgoing request. Updated the four existing TestInvoke call sites for the new Invoke() parameter. Also manually verified dapr invoke --header "Foo=Bar" and the Key=Value format validation on the built binary. go test ./pkg/... (the scope of make test) passes.
  • Documentation: added a --header example to the command's own --help output (in Example); no separate docs.dapr.io page exists for individual invoke flags to extend.

There was no way to send custom HTTP headers to the target app, only
the hardcoded Content-Type. Add a repeatable --header/-H flag in
Key=Value form, parsed into an http.Header and threaded through
Invoke() down to the outgoing request. A prior attempt at this
(dapr#1287) stalled on an unrelated dependency bump, not on the feature
itself, so this keeps the same flag shape and only touches invoke
plumbing.

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested review from a team as code owners September 6, 2026 14:10
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.

Support HTTP Header for dapr invoke

1 participant