add fallback to url generating 404

This commit is contained in:
Trinity Pointard
2018-06-04 21:57:03 +02:00
parent 2fde47d909
commit 8158f19b85
8 changed files with 53 additions and 11 deletions
+11 -1
View File
@@ -1,4 +1,7 @@
use rocket::{ request::Form, response::Redirect};
use rocket::{
request::Form,
response::{Redirect, Flash}
};
use rocket_contrib::Template;
use activity_pub::broadcast;
@@ -9,6 +12,8 @@ use models::{
users::User
};
use utils;
#[get("/~/<_blog>/<slug>/comment")]
fn new(_blog: String, slug: String, user: User, conn: DbConn) -> Template {
let post = Post::find_by_slug(&*conn, slug).unwrap();
@@ -18,6 +23,11 @@ fn new(_blog: String, slug: String, user: User, conn: DbConn) -> Template {
}))
}
#[get("/~/<blog>/<slug>/comment", rank=2)]
fn new_auth(blog: String, slug: String) -> Flash<Redirect>{
utils::requires_login("You need to be logged in order to post a comment", &format!("~/{}/{}/comment", blog, slug))
}
#[derive(FromForm)]
struct CommentQuery {
responding_to: Option<i32>