Skip to content

proxyhttp

proxyhttp contains the narrow HTTP transport helpers shared across other packages.

Use it when you want:

  • one place to build proxy-oriented http.Transport
  • consistent hop-header stripping
  • shared forwarded-header policy
  • light protocol-detection helpers

Main helpers

HelperPurpose
NewTransportBuilds a proxy-oriented http.Transport
RemoveHopHeadersStrips hop-by-hop headers before forwarding
ApplyForwardedHeadersApplies X-Forwarded-* and Via values
IsWebSocketRequestDetects likely WS upgrades
IsAbsoluteURLDetects absolute-URI request strings

Example

go
header := http.Header{}
header.Set("Connection", "keep-alive")

proxyhttp.ApplyForwardedHeaders(header, proxyhttp.ForwardedHeaderConfig{
  ClientIP: "127.0.0.1",
  Proto:    "https",
  Via:      "proxykit",
})
proxyhttp.RemoveHopHeaders(header)

Keep it narrow

proxyhttp should stay a supporting package, not grow into a second transport layer. If logic starts owning routes, storage, or capture policy, it probably belongs somewhere else.

Released under the Apache 2.0 License.