Skip to content

Commit b853df2

Browse files
committed
Make ProxyType a struct
1 parent 42f0e1c commit b853df2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Sources/WSClient/WebSocketClientChannel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct WebSocketClientChannel: ClientConnectionChannel {
6363
let requiresTLS = self.url.scheme == .wss || self.url.scheme == .https
6464
let port = self.url.port ?? (requiresTLS ? 443 : 80)
6565

66-
switch proxy.type
66+
switch proxy.type.value
6767
{
6868
case .http(let connectHeaders):
6969
return setupHTTPProxy(

Sources/WSClient/WebSocketClientConfiguration.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ public struct WebSocketClientConfiguration: Sendable {
6464
/// WebSocket client proxy settings
6565
public struct WebSocketProxySettings: Sendable {
6666
/// Type of proxy
67-
public enum ProxyType: Sendable {
67+
public struct ProxyType: Sendable {
68+
enum Base {
69+
case socks
70+
case http(connectHeaders: HTTPFields = [:])
71+
}
72+
let value: Base
73+
6874
/// SOCKS proxy
69-
case socks
75+
public static var socks: ProxyType { .init(value: .socks) }
7076
/// HTTP proxy
71-
case http(connectHeaders: HTTPFields = [:])
77+
public static func http(connectHeaders: HTTPFields = [:]) -> ProxyType { .init(value: .http(connectHeaders: connectHeaders)) }
7278
}
7379
/// Proxy endpoint hostname
7480
public var host: String

0 commit comments

Comments
 (0)