Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tower-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ auth = ["base64", "validate-request"]
catch-panic = ["tracing", "futures-util/std", "dep:http-body", "dep:http-body-util"]
cors = []
follow-redirect = ["futures-util", "dep:http-body", "iri-string", "tower/util"]
fs = ["futures-core", "futures-util", "dep:http-body", "dep:http-body-util", "tokio/fs", "tokio-util/io", "tokio/io-util", "dep:http-range-header", "mime_guess", "mime", "percent-encoding", "httpdate", "set-status", "futures-util/alloc", "tracing"]
fs = ["futures-core", "futures-util", "dep:http-body", "dep:http-body-util", "tokio/fs", "tokio-util/io", "tokio/io-util", "dep:http-range-header", "mime_guess", "mime", "percent-encoding", "httpdate", "set-status", "futures-util/alloc"]
limit = ["dep:http-body", "dep:http-body-util"]
map-request-body = []
map-response-body = []
Expand Down
6 changes: 5 additions & 1 deletion tower-http/src/services/fs/serve_dir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ impl<F> ServeDir<F> {
/// By default `<ServeDir as Service<_>>::call` will handle IO errors and convert them into
/// responses. It does that by converting [`std::io::ErrorKind::NotFound`] and
/// [`std::io::ErrorKind::PermissionDenied`] to `404 Not Found` and any other error to `500
/// Internal Server Error`. The error will also be logged with `tracing`.
/// Internal Server Error`. The error will also be logged with `tracing` in case the `tracing`
/// crate feature is enabled.
///
/// If you want to manually control how the error response is generated you can make a new
/// service that wraps a `ServeDir` and calls `try_call` instead of `call`.
Expand Down Expand Up @@ -411,7 +412,10 @@ where
.try_call(req)
.map(|result: Result<_, _>| -> Result<_, Infallible> {
let response = result.unwrap_or_else(|err| {
#[cfg(feature = "tracing")]
tracing::error!(error = %err, "Failed to read file");
#[cfg(not(feature = "tracing"))]
let _ = err;

let body = ResponseBody::new(UnsyncBoxBody::new(
Empty::new().map_err(|err| match err {}).boxed_unsync(),
Expand Down
4 changes: 4 additions & 0 deletions tower-http/src/services/fs/serve_dir/open_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ fn append_slash_on_path(uri: Uri) -> Result<Uri, OpenFileOutput> {
};

uri_builder.build().map_err(|err| {
#[cfg(feature = "tracing")]
tracing::error!(?err, "redirect uri failed to build");
#[cfg(not(feature = "tracing"))]
let _ = err;

OpenFileOutput::InvalidRedirectUri
})
}
Expand Down
Loading