Skip to content

Commit a212834

Browse files
committed
switch to using new axum-extra option_layer
1 parent 9b989af commit a212834

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

Diff for: src/web/error.rs

-7
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,6 @@ impl From<anyhow::Error> for AxumNope {
133133

134134
pub(crate) type AxumResult<T> = Result<T, AxumNope>;
135135

136-
/// This function is only necessary because `.option_layer()` changes the error type
137-
/// and we need to change it back. Since the axum middleware has no way of returning
138-
/// an actual error this function should never actually be called.
139-
pub(crate) async fn dummy_error_handler(_err: axum::BoxError) -> http::StatusCode {
140-
http::StatusCode::INTERNAL_SERVER_ERROR
141-
}
142-
143136
#[cfg(test)]
144137
mod tests {
145138
use crate::test::wrapper;

Diff for: src/web/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ mod statics;
3131
use crate::{db::Pool, impl_axum_webpage, Context};
3232
use anyhow::Error;
3333
use axum::{
34-
error_handling::HandleErrorLayer,
3534
extract::Extension,
3635
http::Request as AxumRequest,
3736
http::StatusCode,
@@ -291,8 +290,7 @@ fn apply_middleware(
291290
.layer(Extension(context.config()?))
292291
.layer(Extension(context.storage()?))
293292
.layer(Extension(context.repository_stats_updater()?))
294-
.layer(HandleErrorLayer::new(error::dummy_error_handler))
295-
.option_layer(template_data.map(Extension))
293+
.layer(option_layer(template_data.map(Extension)))
296294
.layer(middleware::from_fn(csp::csp_middleware))
297295
.layer(middleware::from_fn(
298296
page::web_page::render_templates_middleware,

0 commit comments

Comments
 (0)