Provide a 404 page
This commit is contained in:
parent
96e2a362fa
commit
1d998ed2f4
|
@ -124,6 +124,10 @@ struct QueryPaste {
|
|||
no_follow: bool,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "404.html")]
|
||||
struct PasteNotFound;
|
||||
|
||||
impl QueryPaste {
|
||||
fn into_paste(self) -> Paste {
|
||||
let QueryPaste {
|
||||
|
@ -175,7 +179,9 @@ fn display_paste(
|
|||
})
|
||||
.map_err(|e| InternalError::new(e, StatusCode::INTERNAL_SERVER_ERROR).into())
|
||||
.and_then(|(db, paste)| match paste {
|
||||
None => Either::A(future::ok(HttpResponse::NotFound().finish())),
|
||||
None => Either::A(future::ok(
|
||||
HttpResponse::NotFound().body(PasteNotFound.render().unwrap()),
|
||||
)),
|
||||
Some(paste) => Either::B(fetch_languages(&db).and_then(|languages| {
|
||||
DisplayPaste {
|
||||
languages,
|
||||
|
|
5
templates/404.html
Normal file
5
templates/404.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<h1>Paste not found</h1>
|
||||
<p>It may have been automatically deleted after 24 hours.
|
||||
{% endblock content %}
|
Loading…
Reference in New Issue
Block a user