Documentation
¶
Overview ¶
Package proxyhttp provides shared HTTP proxy transport primitives.
The package intentionally stays narrow: transport construction, protocol detection helpers, and hop-by-hop header handling that can be reused by forward, reverse, and MITM proxy implementations.
Example ¶
header := http.Header{}
header.Set("Connection", "keep-alive")
header.Set("Upgrade", "websocket")
ApplyForwardedHeaders(header, ForwardedHeaderConfig{
ClientIP: "127.0.0.1",
Proto: "https",
Via: "proxykit",
})
RemoveHopHeaders(header)
fmt.Println(header.Get("X-Forwarded-For"))
fmt.Println(header.Get("X-Forwarded-Proto"))
fmt.Println(header.Get("Via"))
fmt.Println(header.Get("Connection") == "")
fmt.Println(IsAbsoluteURL("https://example.com/api"))
Output: 127.0.0.1 https proxykit true true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyForwardedHeaders ¶
func ApplyForwardedHeaders(h http.Header, cfg ForwardedHeaderConfig)
ApplyForwardedHeaders sets standard proxy forwarding headers when values are available in cfg.
func IsAbsoluteURL ¶
IsAbsoluteURL reports whether s looks like an absolute URI.
func IsWebSocketRequest ¶
IsWebSocketRequest reports whether the request looks like a WebSocket upgrade.
func NewTransport ¶
func NewTransport(cfg TransportConfig) *http.Transport
NewTransport centralizes proxy-oriented http.Transport creation.
func RemoveHopHeaders ¶
RemoveHopHeaders strips hop-by-hop headers before proxying.
Types ¶
type ForwardedHeaderConfig ¶
type TransportConfig ¶
type TransportConfig struct {
InsecureTLS bool
}
Click to show internal directories.
Click to hide internal directories.