Skip to content

Improve SwiftConfiguration integration#68

Merged
aryan-25 merged 3 commits intoswift-server:mainfrom
aryan-25:improve-swift-configuration
Mar 24, 2026
Merged

Improve SwiftConfiguration integration#68
aryan-25 merged 3 commits intoswift-server:mainfrom
aryan-25:improve-swift-configuration

Conversation

@aryan-25
Copy link
Copy Markdown
Collaborator

@aryan-25 aryan-25 commented Mar 20, 2026

Motivation:

PR #67 refactored NIOHTTPServerConfiguration. As part of this PR, we introduced support for TLS credentials and mTLS trust roots to be provided as PEM files too.

We should update the swift-configuration integration to match these changes. We should also use this opportunity to better document the possible keys and supported values in a DocC article, as the current documentation is spread inline across multiple types.

Modifications:

  • Replaced the "security" key (5 values: "plaintext", "tls", "reloadingTLS", "mTLS", "reloadingMTLS") with a "transportSecurity.mode" key (3 values: "plaintext", "tls", "mTLS").
  • Added a "transportSecurity.credentialSource" key ("inline", "file"), and a "transportSecurity.trustRootsSource" key ("inline", "file", "systemDefaults", "customCertificateVerificationCallback").
  • Renamed/rescoped several configuration keys for clarity ("supportedHTTPVersions""http.versions", "low"/"high""lowWatermark"/"highWatermark", scoped "gracefulShutdown").
  • Added a DocC article with a complete configuration key reference table, example JSON, and narrative documentation.

Result:

Improved swift-configuration integration.

@aryan-25 aryan-25 added the ⚠️ semver/major Breaks existing public API. label Mar 20, 2026
@aryan-25 aryan-25 requested a review from czechboy0 March 24, 2026 09:04
Copy link
Copy Markdown

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions, otherwise lgtm

/// - ``BindTarget`` - Provide under key `"bindTarget"` (keys listed in ``BindTarget/init(config:)``).
///
/// - ``SupportedHTTPVersions`` - Provide under key `"supportedHTTPVersions"` (keys listed in
/// - ``SupportedHTTPVersions`` - Provide under key `"http.versions"` (supported values listed in
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The input to the init(config:) of SupportedHTTPVersions is scoped to http only, the versions is then parsed internally and that type is HTTPVersionKind instead.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry, SupportedHTTPVersions was a remnant from working on #67, but we eventually settled on using Set<HTTPVersion> to represent supported HTTP versions instead. I've updated the docs.

/// - `maxConcurrentStreams` (int, optional, default: 100): The maximum number of concurrent streams in an HTTP/2
/// - `maxConcurrentStreams` (int, optional, default: nil): The maximum number of concurrent streams in an HTTP/2
/// connection.
/// - `gracefulShutdown.maximumGracefulShutdownDuration` (int, optional, default: nil): The maximum amount of time
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - `gracefulShutdown.maximumGracefulShutdownDuration` (int, optional, default: nil): The maximum amount of time
/// - `gracefulShutdown.maximumDuration` (int, optional, default: nil): The maximum amount of time

Suggestion

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

I realised we also have a maximumGracefulShutdownDuration property under the GracefulShutdownConfiguration type in NIOHTTPServerConfiguration:

public var maximumGracefulShutdownDuration: Duration?

I'm going to address that in a separate PR where we will also make the other NIOHTTP2ServerConnectionManagementHandler options configurable; currently we only set the maxGraceTime option:

maxIdleTime: nil,
maxAge: nil,
maxGraceTime: configuration.gracefulShutdown.maximumGracefulShutdownDuration
.map { TimeAmount($0) },
keepalive: nil

> Important: HTTP/2 cannot be served over plaintext. If `"http2"` is included in `http.versions`, the transport
> security must be set to `"tls"` or `"mTLS"`.

| Prefix | Configuration Key | Type | Required/Optional | Default |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table is a really good idea, I'll steal it for other projects too :)

@aryan-25 aryan-25 merged commit 593b7ca into swift-server:main Mar 24, 2026
25 of 26 checks passed
@aryan-25 aryan-25 deleted the improve-swift-configuration branch March 24, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ semver/major Breaks existing public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants