about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/handlers.rs9
-rw-r--r--src/main.rs2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index c31cdf679bb7..3af8a8c40929 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -81,6 +81,15 @@ pub fn forum_thread(state: State<AppState>, thread_id: Path<i32>) -> ConverseRes
         .responder()
 }
 
+/// This handler presents the user with the "New Thread" form.
+pub fn new_thread(state: State<AppState>) -> Result<HttpResponse> {
+    let ctx = tera::Context::new();
+    let body = state.tera.render("new-thread.html", &ctx)?;
+    Ok(HttpResponse::Ok()
+       .content_type("text/html")
+       .body(body))
+}
+
 #[derive(Deserialize)]
 pub struct NewThreadForm {
     pub title: String,
diff --git a/src/main.rs b/src/main.rs
index 8400f570a9be..ef5d2e92f1b4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -109,10 +109,10 @@ fn main() {
 
         App::with_state(state)
             .middleware(Logger::default())
-            // TODO: Configure session backend with more secure settings.
             .middleware(sessions)
             .middleware(RequireLogin)
             .resource("/", |r| r.method(Method::GET).with(forum_index))
+            .resource("/thread/new", |r| r.method(Method::GET).with(new_thread))
             .resource("/thread/submit", |r| r.method(Method::POST).with3(submit_thread))
             .resource("/thread/reply", |r| r.method(Method::POST).with3(reply_thread))
             .resource("/thread/{id}", |r| r.method(Method::GET).with2(forum_thread))