diff --git a/Sources/HTTPServer/SocketAddress.swift b/Sources/HTTPServer/SocketAddress.swift index 3b56809..4dad73a 100644 --- a/Sources/HTTPServer/SocketAddress.swift +++ b/Sources/HTTPServer/SocketAddress.swift @@ -83,4 +83,25 @@ public struct SocketAddress: Hashable, Sendable { return address } + + /// The ``SocketAddress``'s host. + public var host: String { + switch self.base { + case .ipv4(let ipv4): + return ipv4.host + case .ipv6(let ipv6): + return ipv6.host + } + } + + /// The ``SocketAddress``'s port. + public var port: Int { + switch self.base { + case .ipv4(let ipv4): + return ipv4.port + + case .ipv6(let ipv6): + return ipv6.port + } + } } diff --git a/Tests/HTTPServerTests/Utilities/SocketAddress.swift b/Tests/HTTPServerTests/Utilities/SocketAddress.swift deleted file mode 100644 index a6f5e98..0000000 --- a/Tests/HTTPServerTests/Utilities/SocketAddress.swift +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift HTTP Server open source project -// -// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -@testable import HTTPServer - -extension HTTPServer.SocketAddress { - var host: String { - switch self.base { - case .ipv4(let ipv4): - return ipv4.host - case .ipv6(let ipv6): - return ipv6.host - } - } - - var port: Int { - switch self.base { - case .ipv4(let ipv4): - return ipv4.port - case .ipv6(let ipv6): - return ipv6.port - } - } -}