Skip to content

fix(web): expose AppConfig constructor for custom servers - #4243

Open
akasakariko wants to merge 4 commits into
actix:mainfrom
akasakariko:fix/app-config-public-constructor
Open

akasakariko wants to merge 4 commits into
actix:mainfrom
akasakariko:fix/app-config-public-constructor

Conversation

@akasakariko

@akasakariko akasakariko commented Sep 14, 2026 •

Copy link
Copy Markdown

PR Type

Bug Fix

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

Custom servers built with actix_server::Server cannot currently construct a supported AppConfig with their actual listener metadata. Falling back to AppConfig::default() can give requests the wrong local address, hostname, and scheme, and produce incorrect generated URLs.

Expose and document the existing AppConfig::new constructor, and update the low-level server example to derive its configuration from the bound listener. This is an additive API change; existing default values and the hidden test constructor are preserved.

Regression tests cover request configuration, scheme/host fallbacks and URL generation, header/URI precedence, and two listeners sharing one worker.

Closes #3180.

Validation

The new external-crate regression tests fail before the change with E0624 because the constructor is private, and pass after the change.

  • cargo +stable test -p actix-web --lib --tests --all-features --locked: 479 passed, 1 existing ignored test.
  • cargo +stable test -p actix-web --doc --locked: 193 passed, 7 existing ignored doctests.
  • Rust 1.88.0: all 3 new regression tests and the minimum-feature build passed.
  • Stable minimum-feature build and actix-http's actix-web example build passed.
  • Clippy for actix-web and actix-http, rustdoc with warnings denied, Rustfmt, and changelog formatting checks passed.

@github-actions github-actions Bot added A-http project: actix-http A-web project: actix-web labels Sep 14, 2026
@robjtede

robjtede commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

I'm interested in addressing the issue that this fixes so I'll check this out once you've undrafted and think it's ready.

…ic-constructor

# Conflicts:
#	actix-web/CHANGES.md
@akasakariko

Copy link
Copy Markdown
Author

Closing and reopening as a non-draft PR. I wasn't able to mark this draft ready for review (GitHub returns a permission error for the author on this fork PR), so the replacement PR will be opened ready for review. Same branch and commits.

@akasakariko akasakariko reopened this Sep 25, 2026
@akasakariko

Copy link
Copy Markdown
Author

Re-closing to open a replacement non-draft PR (author cannot undraft this one; CLI create also hit a permission error, so opening via the web UI next).

@akasakariko akasakariko reopened this Sep 25, 2026
@akasakariko
akasakariko marked this pull request as ready for review September 25, 2026 21:54
@akasakariko

Copy link
Copy Markdown
Author

Marked ready for review. Earlier undraft attempts failed because this account had already hit the repository open (non-draft) PR limit; temporarily converting #4238 back to draft freed the slot.

@akasakariko

Copy link
Copy Markdown
Author

@robjtede Friendly ping — this is ready for review now and CI is green. Let me know if you'd like any changes.

@akasakariko

Copy link
Copy Markdown
Author

Updated in 72957b7

  • Merged main at 15fd3ff3 and resolved the changelog conflict, keeping the constructor entry under Unreleased
  • Existing constructor implementation, example changes, and regression tests are unchanged
  • GitHub now reports no merge conflicts

Validation

Local checks passed on macOS with stable Rust and MSRV 1.88

Commands and results
Command Result
cargo test --locked -p actix-web --all-features --test test_app_config 3 passed
cargo test --locked -p actix-web -p actix-http --all-features --lib --tests 816 passed, 2 existing ignored
cargo test --locked -p actix-web -p actix-http --all-features --doc 238 passed, 8 existing ignored
cargo check --locked -p actix-http --example actix-web Passed
cargo check --locked -p actix-web --no-default-features Passed
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings Passed
cargo +1.88.0 test --locked -p actix-web --all-features --test test_app_config 3 passed
cargo +1.88.0 check --locked --workspace --all-targets --all-features Passed
cargo +1.88.0 check --locked -p actix-web --no-default-features Passed
cargo +nightly-2026-09-15 fmt --all -- --check Passed
npx -y prettier --check actix-web/CHANGES.md Passed
git diff --check and git diff --cached --check Passed

Cargo reported the existing non-fatal actix-router/Cargo.toml warning for the unused lints.cargo key

Remaining CI blocker

GitHub checks finished with 15 passed, 1 failed, and 1 skipped

  • Linux, macOS, and Windows tests passed on stable and MSRV, along with doctests, coverage, Clippy, formatting, and semver checks
  • cargo-deny failed on rustls advisories RUSTSEC-2026-0346, RUSTSEC-2026-0347, RUSTSEC-2026-0348, and RUSTSEC-2026-0349
  • The affected versions include rustls 0.20.9, 0.21.12, 0.22.4, and 0.23.45; updating only the latest rustls line would not clear the older supported lines
  • Cargo.lock, deny.toml, and the lint workflow are identical to main at 15fd3ff3, so this failure is outside the constructor change
  • No advisory exceptions or check bypasses were added
  • check-external-types was skipped by the workflow

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-http project: actix-http A-web project: actix-web B-semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple services over multiple sockets example creates an incorrect AppConfig

2 participants