proxyhttp

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

func IsAbsoluteURL(s string) bool

IsAbsoluteURL reports whether s looks like an absolute URI.

func IsWebSocketRequest

func IsWebSocketRequest(r *http.Request) bool

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

func RemoveHopHeaders(h http.Header)

RemoveHopHeaders strips hop-by-hop headers before proxying.

Types

type ForwardedHeaderConfig

type ForwardedHeaderConfig struct {
	ClientIP string
	Proto    string
	Via      string
}

type TransportConfig

type TransportConfig struct {
	InsecureTLS bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL