Merge branch 'ensure-404-page-works' into 'master'
Ensure 404 page works See merge request pastebinrun/pastebinrun!159
This commit is contained in:
commit
53455e21c7
|
@ -110,11 +110,11 @@ fn options(pool: PgPool) -> BoxedFilter<(impl Reply,)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn raw_paste(pool: PgPool) -> BoxedFilter<(impl Reply,)> {
|
fn raw_paste(pool: PgPool) -> BoxedFilter<(impl Reply,)> {
|
||||||
warp::get()
|
with_ext("txt")
|
||||||
.and(with_ext("txt"))
|
.and(warp::get())
|
||||||
.and(connection(pool))
|
.and(connection(pool))
|
||||||
.and_then(raw_paste::raw_paste)
|
.and_then(raw_paste::raw_paste)
|
||||||
.or(warp::options().and(with_ext("txt")).map(|_| {
|
.or(with_ext("txt").and(warp::options()).map(|_| {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
|
.header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
|
||||||
.header(ACCESS_CONTROL_ALLOW_METHODS, "GET")
|
.header(ACCESS_CONTROL_ALLOW_METHODS, "GET")
|
||||||
|
@ -454,4 +454,18 @@ mod test {
|
||||||
StatusCode::OK,
|
StatusCode::OK,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[cfg_attr(not(feature = "database_tests"), ignore)]
|
||||||
|
async fn error_404() {
|
||||||
|
assert_eq!(
|
||||||
|
warp::test::request()
|
||||||
|
.path("/404")
|
||||||
|
.method("GET")
|
||||||
|
.reply(&*ROUTES)
|
||||||
|
.await
|
||||||
|
.status(),
|
||||||
|
StatusCode::NOT_FOUND,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user