Skip to content

Conversation

@aryan-25
Copy link
Collaborator

Motivation:

Users should be able to initialize NIOHTTPServerConfiguration via swift-configuration.

Modifications:

Added a new initializer on NIOHTTPServerConfiguration, which has a Configuration.ConfigReader argument. This initializer populates the four child types (BindTarget, TransportSecurity, BackpressureStrategy, and HTTP2) from the reader.

Result:

Support for swift-configuration added.

@aryan-25 aryan-25 added the 🆕 semver/minor Adds new public API. label Jan 15, 2026
@aryan-25
Copy link
Collaborator Author

aryan-25 commented Jan 15, 2026

For ease of reference, the table below displays the hierarchy of keys and associated information. Key names / hierarchy / type / default values are very much open for discussion.

Prefix Configuration Key Type Required/Optional Default
bindTarget host string required -
bindTarget port int required -
transportSecurity security string required (permitted values: "plaintext", "tls", "reloadingTLS", "mTLS", "reloadingMTLS") -
transportSecurity certificateChainPEMString string required (for "tls" and "reloadingTLS") -
transportSecurity privateKeyPEMString string required (for "tls" and "reloadingTLS", secret) -
transportSecurity trustRoots string array optional (for "mTLS" and "reloadingMTLS") system trust roots
transportSecurity certificateVerificationMode string required (for "mTLS" and "reloadingMTLS", permitted values: "optionalVerification", "noHostnameVerification") -
transportSecurity certificateChainPEMPath string required (for "reloadingTLS" and "reloadingMTLS") -
transportSecurity privateKeyPEMPath string required (for "reloadingTLS" and "reloadingMTLS") -
transportSecurity refreshInterval int optional (for "reloadingTLS" and "reloadingMTLS") 30
backpressureStrategy low int optional 2
backpressureStrategy high int optional 10
http2 maxFrameSize int optional 2^14
http2 targetWindowSize int optional 2^16 - 1
http2 maxConcurrentStreams int optional 100

Copy link
Collaborator

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

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

I think it may be worth adding these APIs (and the swift-configuration dependency) behind a trait, to avoid forcing this dependency on everyone.

https://docs.swift.org/swiftpm/documentation/packagemanagerdocs/packagetraits/

Comment on lines 216 to 218
static let DEFAULT_MAX_FRAME_SIZE = 1 << 14
static let DEFAULT_TARGET_WINDOW_SIZE = (1 << 16) - 1
static let DEFAULT_MAX_CONCURRENT_STREAMS: Int? = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Style nit: I think we generally use camel case for constants. Also prefer to use inlinable computed static vars instead, for performance.

let config = ConfigReader(provider: provider)
let snapshot = config.snapshot()

#expect(throws: Error.self) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we throw a more descriptive error here (and elsewhere)?

}
}

// MARK: - TransportSecurity mTLS Tests
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit, but we can have separate suites for each group of tests instead of having these marks and prefixing the test names with the group name.

@czechboy0
Copy link

I think it may be worth adding these APIs (and the swift-configuration dependency) behind a trait, to avoid forcing this dependency on everyone.

That's certainly reasonable, let's just make sure it's behind a default trait. Generally we want ecosystem API package integration to be either built-in, or behind a default trait. We shouldn't put such integrations (logs/metrics/tracing/configuration/service lifecycle) behind opt-in traits, as that'd put quite a lot of obstacles in the way of folks just getting started.

@aryan-25 aryan-25 requested a review from gjcairo January 20, 2026 17:41
@aryan-25 aryan-25 merged commit 2832c6b into swift-server:main Jan 21, 2026
19 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants