blob: 8fd61c5f284c0d08d03637d350be492bd6125ff7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
use rocket::request::Form;
use rocket::response::Redirect;
use crate::db::*;
use crate::structures::*;
// POST: Create a new thread.
#[post("/post", data = "<thread>")]
pub fn post(thread: Form<Thread>) -> Redirect {
// Pretty rudimentary error handling.
match new_thread(Thread {
board: thread.board.clone(),
name: thread.name.clone(),
comment: thread.comment.clone(),
}) {
Ok(()) => { },
Err(why) => println!("Error creating new thread: {}", why)
}
// Redirect to all posts.
Redirect::to(format!("/board/{}", thread.board))
}
|