Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ let extraSettings: [SwiftSetting] = [
.enableUpcomingFeature("InferIsolatedConformances"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("InternalImportsByDefault"),
.unsafeFlags([
"-Xfrontend",
"-disable-availability-checking",
]),
.enableUpcomingFeature("InternalImportsByDefault")
]

let package = Package(
Expand Down
2 changes: 2 additions & 0 deletions Sources/Example/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Middleware
import X509

@main
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct Example {
static func main() async throws {
try await serve()
Expand Down Expand Up @@ -68,6 +69,7 @@ struct Example {

// MARK: - Server Extensions

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
extension Server {
/// Serve HTTP requests using a middleware chain built with the provided builder
/// This method handles the type inference for HTTP middleware components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import HTTPTypes
import Logging
import Middleware

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct HTTPRequestLoggingMiddleware<
RequestConludingAsyncReader: ConcludingAsyncReader,
ResponseConcludingAsyncWriter: ConcludingAsyncWriter & ~Copyable
Expand Down Expand Up @@ -62,6 +63,7 @@ where
}
}

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct HTTPRequestLoggingConcludingAsyncReader<
Base: ConcludingAsyncReader
>: ConcludingAsyncReader
Expand Down Expand Up @@ -123,6 +125,7 @@ where
}
}

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct HTTPResponseLoggingConcludingAsyncWriter<
Base: ConcludingAsyncWriter & ~Copyable
>: ConcludingAsyncWriter, ~Copyable
Expand Down
1 change: 1 addition & 0 deletions Sources/Example/Middlewares/RouteHandlerMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import HTTPServer
import HTTPTypes
import Middleware

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct RouteHandlerMiddleware<
RequestConcludingAsyncReader: ConcludingAsyncReader & Copyable,
ResponseConcludingAsyncWriter: ConcludingAsyncWriter & ~Copyable,
Expand Down
2 changes: 2 additions & 0 deletions Sources/Example/Middlewares/TimeoutMiddleware.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Middleware

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct TimeoutMiddleware<Input>: Middleware {
func intercept(input: Input, next: (Input) async throws -> Void) async throws {
try await withoutActuallyEscaping(next) { next in
Expand All @@ -21,6 +22,7 @@ package struct TimeOutError: Error {
var underlying: any Error
}

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public func withTimeout<T: Sendable, Clock: _Concurrency.Clock>(
in timeout: Clock.Duration,
clock: Clock,
Expand Down
1 change: 1 addition & 0 deletions Sources/Example/Middlewares/TracingMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import HTTPTypes
import Middleware
import Tracing

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
struct TracingMiddleware<Input>: Middleware {
func intercept(
input: Input,
Expand Down
2 changes: 2 additions & 0 deletions Sources/HTTPServer/AsyncPrimitives/AsyncReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
///
/// ``AsyncReader`` defines an interface for types that can asynchronously read elements
/// of a specified type from a source.
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public protocol AsyncReader<ReadElement, ReadFailure> {
/// The type of elements that can be read by this reader.
associatedtype ReadElement: ~Copyable, ~Escapable
Expand Down Expand Up @@ -44,6 +45,7 @@ public protocol AsyncReader<ReadElement, ReadFailure> {
) async throws(ReadFailure) -> Return
}

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
extension AsyncReader {
/// Collects elements from the reader up to a specified limit and processes them with a body function.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// provide a conclusive element after all reads are completed. This is particularly useful
/// for streams that have meaningful completion states beyond just terminating, such as
/// HTTP responses that include headers after the body is fully read.
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public protocol ConcludingAsyncReader<Underlying, FinalElement> {
/// The underlying asynchronous reader type that produces elements.
associatedtype Underlying: AsyncReader, ~Copyable, ~Escapable
Expand Down Expand Up @@ -37,6 +38,7 @@ public protocol ConcludingAsyncReader<Underlying, FinalElement> {
) async throws -> (Return, FinalElement)
}

@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
extension ConcludingAsyncReader {
/// Processes the underlying async reader until completion and returns only the final element.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import NIOHTTPTypes
/// and concluding with the HTTP trailer fields received at the end of the request. This type
/// follows the ``ConcludingAsyncReader`` pattern, which allows for asynchronous consumption of
/// a stream with a conclusive final element.
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public struct HTTPRequestConcludingAsyncReader: ConcludingAsyncReader {
/// A reader for HTTP request body chunks that implements the ``AsyncReader`` protocol.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import NIOHTTPTypes
///
/// This writer is designed to work with HTTP responses where the body is streamed in chunks
/// and potentially followed by trailer fields.
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public struct HTTPResponseConcludingAsyncWriter: ConcludingAsyncWriter, ~Copyable {
/// A writer for HTTP response body chunks that implements the ``AsyncWriter`` protocol.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/HTTPServer/HTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import SwiftASN1
/// }
/// }
/// ```
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public final class Server<RequestHandler: HTTPServerRequestHandler> {
/// Starts an HTTP server with a closure-based request handler.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/HTTPServer/HTTPServerClosureRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public import HTTPTypes
/// }
/// }
/// ```
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public struct HTTPServerClosureRequestHandler: HTTPServerRequestHandler {
/// The underlying closure that handles HTTP requests
private let _handler:
Expand Down
1 change: 1 addition & 0 deletions Sources/HTTPServer/HTTPServerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public import X509
///
/// This structure contains all the necessary configuration options for setting up
/// and running an HTTP server, including network binding and TLS settings.
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public struct HTTPServerConfiguration: Sendable {
/// Specifies where the server should bind and listen for incoming connections.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/HTTPServer/HTTPServerRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public import HTTPTypes
/// }
/// }
/// ```
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
public protocol HTTPServerRequestHandler: Sendable {
/// Handles an incoming HTTP request and generates a response.
///
Expand Down
2 changes: 1 addition & 1 deletion Tests/HTTPServerTests/HTTPServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Testing
@Suite
struct HTTPServerTests {
@Test
@available(macOS 26.0, *)
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
func testSimpleAPI() async throws {
try await HTTPServer.Server
.serve(
Expand Down