Skip to content

Proposal: add ModifyRequest func(*http.Request) to HTTP client transports #533

@findleyr

Description

@findleyr

Following up on #522, where we discussed making it easier to modify HTTP client transport requests, for example by adding headers, we propose the following two new options:

type StreamableClientTransport struct {
  ...
  // If set, ModifyRequest is called before each outgoing HTTP request made by the client
  // connection. It can be use to, for example, add headers to outgoing requests.
  ModifyRequest func(*http.Request)
}

type SSEClientTransport struct {
  ...
  // <ditto>
  ModifyRequest func(*http.Request)
}

We believe these options will make it easier to do things like add auth headers. Currently, this can be achieved using the HTTPClient field, but only in the roundtripper, which requires cloning the request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestproposalA proposal for an a new API or behavior. See CONTRIBUTING.md.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions