Skip to content

refactor: Use axum for "mdbook serve" #2359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

audunhalland
Copy link

@audunhalland audunhalland commented Apr 7, 2024

This in my opinion brings mdbook's dependencies more in line with "the state of the art" of the Rust HTTP ecosystem.
It pulls in hyper v1 and uses tower-http for filesystem serving functions.

I've manually tested serve with the test_book:

  • serving pages from the book works
  • websocket-based auto-reload works
  • 404 page works

I can't guarantee though that there are no regressions. I did not find integrations tests for the serve command.

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Apr 7, 2024
@paolobarbolini
Copy link
Contributor

FWIW this seems the right call, as warp is still on hyper v0.14 and looking at their repository it gets almost no maintenance.

@audunhalland
Copy link
Author

rebased, squashed commits; upgraded to axum 0.8.1.

Copy link
Contributor

@szabgab szabgab 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 the change raising msrv to 1.75 should be removed from the PR.
Especially as mdbook is now on 1.77 already.

@szabgab
Copy link
Contributor

szabgab commented Mar 6, 2025

Thanks for the update.

I am not familiar with axum so I can't comment on the code, but I tried the PR locally and it works on Linux.

My only thought was that by replacing a small framework with a larger one we might make the executable much larger.
So I checked the size of the target/release/mdbook executable on Ubuntu Linux after generating it with the cargo build --locked --bin mdbook --release command:

  • on master 14,955,672
  • with axum 13,146,536

So somehow this change also reduces the size of the executable by some 13%. Any idea how and why?

@audunhalland
Copy link
Author

audunhalland commented Mar 6, 2025

Speculation:

  • The http crate has been unified on version 1 (I see no other unification in the Cargo.lock diff)
  • This change removes support for HTTP/2 as axum default features has been turned off (edit: actually after checking: http2 is not in the default feature set of axum)

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented May 5, 2025

☔ The latest upstream changes (possibly 9822c2a) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants