Skip to content

Commit

Permalink
Merge pull request #3259 from dougm/vapi-operation-id
Browse files Browse the repository at this point in the history
vapi: add support for OperationID header
  • Loading branch information
dougm authored Oct 13, 2023
2 parents 8726f22 + 0434fd2 commit c4befe0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vapi/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/vmware/govmomi/vapi/internal"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)

// Client extends soap.Client to support JSON encoding, while inheriting security features, debug tracing and session persistence.
Expand Down Expand Up @@ -179,6 +180,11 @@ func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{})
}
}

// OperationID (see soap.Client.soapRoundTrip)
if id, ok := ctx.Value(types.ID{}).(string); ok {
req.Header.Add("X-Request-ID", id)
}

if headers, ok := ctx.Value(headersContext{}).(http.Header); ok {
for k, v := range headers {
for _, v := range v {
Expand Down

0 comments on commit c4befe0

Please sign in to comment.