diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-04-09T21·37+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2018-04-09T21·37+0200 |
commit | 103a59485fbb47e44740a976fb846791b8df0802 (patch) | |
tree | 864a7b0c74f79124785df51c70c34495b0f1bf10 /src | |
parent | fb7df7a34680524cd269d12e6b49fa487cef38b3 (diff) |
feat(handlers/templates): Add "New Thread" handler and template
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers.rs | 9 | ||||
-rw-r--r-- | src/main.rs | 2 |
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)) |