Documentation
¶
Index ¶
- Variables
- type Config
- type Factory
- type HTTPTransport
- type Manager
- func (m *Manager) Client(timeout int) *http.Client
- func (m *Manager) Close() error
- func (m *Manager) GetConfig(transportType TransportType) (*Config, bool)
- func (m *Manager) GetTransport(transportType TransportType) (Transport, error)
- func (m *Manager) GetTransportForURL(urlScheme string) (Transport, error)
- func (m *Manager) RegisterTransport(transportType TransportType, transport Transport)
- func (m *Manager) RegisterTransportWithConfig(transportType TransportType, config *Config) error
- func (m *Manager) RoundTrip(req *http.Request) (*http.Response, error)
- func (m *Manager) SupportedSchemes() []string
- type SSHTunnelTransport
- type Transport
- type TransportType
- type ZitiTransport
- func (t *ZitiTransport) Client() *http.Client
- func (t *ZitiTransport) Close() error
- func (t *ZitiTransport) Dial(serviceName string) (net.Conn, error)
- func (t *ZitiTransport) GetZitiContext() ziti.Context
- func (t *ZitiTransport) ListServices() ([]string, error)
- func (t *ZitiTransport) Listen(serviceName string) (net.Listener, error)
- func (t *ZitiTransport) RoundTrip(req *http.Request) (*http.Response, error)
Constants ¶
This section is empty.
Variables ¶
var URLScheme = map[string]TransportType{ "http": TransportHTTP, "https": TransportHTTP, "ssh": TransportSSH, "ssh+http": TransportSSH, "ssh+https": TransportSSH, "ziti": TransportZiti, "ziti+http": TransportZiti, }
URLScheme maps URL schemes to transport types
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// SSH configuration (for SSH transport)
SSHUser string
SSHHost string
SSHPort int
SSHKeyFile string
SSHPassword string
SSHKnownHosts string
// Ziti configuration (for Ziti transport)
ZitiIdentityFile string
ZitiIdentityJSON string
// HTTP configuration (for all transports)
Timeout int // seconds
MaxIdleConns int
MaxIdleConnsPerHost int
IdleConnTimeout int // seconds
}
Config holds configuration for transport creation
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults
type Factory ¶
type Factory interface {
CreateTransport(ctx context.Context, transportType TransportType, config *Config) (Transport, error)
}
Factory creates a Transport based on the configuration and type
type HTTPTransport ¶
type HTTPTransport struct {
// contains filtered or unexported fields
}
HTTPTransport implements Transport for direct HTTP/HTTPS connections. This wraps the standard library's http.Transport with configured timeouts and connection pooling.
func NewHTTPTransport ¶
func NewHTTPTransport(ctx context.Context, config *Config) (*HTTPTransport, error)
NewHTTPTransport creates a new HTTP transport with the given configuration
func (*HTTPTransport) Client ¶
func (t *HTTPTransport) Client() *http.Client
Client returns the underlying http.Client for direct use
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple transports and routes requests based on URL scheme. This allows WHEN to support multiple network transports transparently.
func DefaultManager ¶
DefaultManager creates a manager with HTTP transport pre-configured
func DefaultManagerWithAllTransports ¶
func DefaultManagerWithAllTransports(ctx context.Context, httpConfig, sshConfig, zitiConfig *Config) (*Manager, error)
DefaultManagerWithAllTransports creates a manager with all transports configured from environment
func NewManager ¶
NewManager creates a new transport manager
func (*Manager) GetConfig ¶
func (m *Manager) GetConfig(transportType TransportType) (*Config, bool)
GetConfig returns the configuration for a transport type
func (*Manager) GetTransport ¶
func (m *Manager) GetTransport(transportType TransportType) (Transport, error)
GetTransport returns the transport for a given type
func (*Manager) GetTransportForURL ¶
GetTransportForURL returns the appropriate transport based on URL scheme
func (*Manager) RegisterTransport ¶
func (m *Manager) RegisterTransport(transportType TransportType, transport Transport)
RegisterTransport registers a transport for a specific type
func (*Manager) RegisterTransportWithConfig ¶
func (m *Manager) RegisterTransportWithConfig(transportType TransportType, config *Config) error
RegisterTransportWithConfig registers and creates a transport based on configuration
func (*Manager) RoundTrip ¶
RoundTrip implements http.RoundTripper interface. This routes the request to the appropriate transport based on URL scheme.
func (*Manager) SupportedSchemes ¶
SupportedSchemes returns a list of supported URL schemes
type SSHTunnelTransport ¶
type SSHTunnelTransport struct {
// contains filtered or unexported fields
}
SSHTunnelTransport implements Transport for HTTP over SSH tunnels. This creates SSH connections to remote hosts and tunnels HTTP traffic through them.
func NewSSHTunnelTransport ¶
func NewSSHTunnelTransport(ctx context.Context, config *Config) (*SSHTunnelTransport, error)
NewSSHTunnelTransport creates a new SSH tunnel transport
func (*SSHTunnelTransport) Client ¶
func (t *SSHTunnelTransport) Client() *http.Client
Client returns the underlying http.Client for direct use
func (*SSHTunnelTransport) Close ¶
func (t *SSHTunnelTransport) Close() error
Close closes the SSH connection and all tunnels
func (*SSHTunnelTransport) CreateLocalForward ¶
func (t *SSHTunnelTransport) CreateLocalForward(localAddr, remoteAddr string) (net.Listener, error)
CreateLocalForward creates a local port forward through the SSH tunnel This can be used for long-lived tunnels to specific services
type Transport ¶
type Transport interface {
// RoundTrip executes a single HTTP transaction, returning the response.
// This is compatible with http.RoundTripper interface.
RoundTrip(*http.Request) (*http.Response, error)
// Close closes any underlying connections and cleans up resources.
Close() error
}
Transport represents a network transport mechanism for HTTP requests. This abstraction allows WHEN to support multiple transport layers: - Direct HTTP/HTTPS - HTTP over SSH tunnels - HTTP over OpenZiti overlay networks
type TransportType ¶
type TransportType string
TransportType identifies the type of transport
const ( TransportHTTP TransportType = "http" TransportSSH TransportType = "ssh" TransportZiti TransportType = "ziti" )
type ZitiTransport ¶
type ZitiTransport struct {
// contains filtered or unexported fields
}
ZitiTransport implements Transport for HTTP over OpenZiti overlay networks. This provides zero-trust networking with built-in encryption and identity-based access control.
func NewZitiTransport ¶
func NewZitiTransport(ctx context.Context, cfg *Config) (*ZitiTransport, error)
NewZitiTransport creates a new OpenZiti transport
func (*ZitiTransport) Client ¶
func (t *ZitiTransport) Client() *http.Client
Client returns the underlying http.Client for direct use
func (*ZitiTransport) Dial ¶
func (t *ZitiTransport) Dial(serviceName string) (net.Conn, error)
Dial creates a direct connection to a Ziti service This can be used for non-HTTP protocols over Ziti
func (*ZitiTransport) GetZitiContext ¶
func (t *ZitiTransport) GetZitiContext() ziti.Context
GetZitiContext returns the underlying Ziti context for direct service operations
func (*ZitiTransport) ListServices ¶
func (t *ZitiTransport) ListServices() ([]string, error)
ListServices returns the list of available Ziti services