Skip to content
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

tower-http 0.5.0 ServeDir fail to compile with axum axum v0.6.20 #2333

Closed
1 task done
jeremychone opened this issue Nov 21, 2023 · 2 comments
Closed
1 task done

tower-http 0.5.0 ServeDir fail to compile with axum axum v0.6.20 #2333

jeremychone opened this issue Nov 21, 2023 · 2 comments

Comments

@jeremychone
Copy link

  • I have looked for existing issues (including closed) about this

Bug Report

Version

├── axum v0.6.20
│   ├── axum-core v0.3.4
│   ├── axum-core v0.3.4 (*)

Platform

M3 Mac Book Pro

Darwin mx.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:33:00 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6031 arm64

Crates

tower-http = { version = "0.5", features = ["fs"] }

features = ["full"] also result in the same compile error.

Description

When using the new tower-http 0.5.0 with ServeDir,

pub fn serve_dir() -> MethodRouter {
	async fn handle_404() -> (StatusCode, &'static str) {
		(StatusCode::NOT_FOUND, "Resource not found.")
	}
	any_service(ServeDir::new("./").not_found_service(handle_404.into_service()))
}

This work with tower-http 0.4, but fail to compile with tower-http 0.5 with the following error:

the trait bound `tower_http::services::ServeDir<tower_http::set_status::SetStatus<axum::handler::HandlerService<fn() -> impl std::future::Future<Output = (axum::http::StatusCode, &'static str)> {web::routes_static::serve_dir::handle_404}, ((),), (), _>>>: tower_service::Service<axum::http::Request<_>>` is not satisfied
the trait `tower_service::Service<http::request::Request<ReqBody>>` is implemented for `tower_http::services::ServeDir<F>`

Something like that fail as well:

Router::new().nest_service("/", get_service(ServeDir::new("./")));
@mo8it
Copy link

mo8it commented Nov 21, 2023

Strongly related to #2332

Support of the new 0.5 version of tower-http is planned in the next Axum release 0.7.
Until then, you need to use a tower-http version below 0.5.

This issue can be closed.

@jeremychone
Copy link
Author

Cool, thanks for the response. Sorry. somehow I did not find the issue. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants