From 5d6243ae265430afd8b839e690ac93f3c19de908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Val=C3=A9rio?= Date: Sat, 30 Mar 2019 22:49:47 +0000 Subject: [PATCH] added post route for the hub functionality --- src/controllers.rs | 8 ++++++-- src/main.rs | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/controllers.rs b/src/controllers.rs index 24bf1f3..85caee9 100644 --- a/src/controllers.rs +++ b/src/controllers.rs @@ -1,7 +1,11 @@ use actix_web::{HttpRequest, Responder}; -pub fn index(_req: &HttpRequest) -> impl Responder { - "Hello world!" +pub fn index(_req: HttpRequest) -> impl Responder { + "Hello get!" +} + +pub fn hub(_req: HttpRequest) -> impl Responder { + "Hello post!" } #[cfg(test)] diff --git a/src/main.rs b/src/main.rs index 5990cf3..43bdc56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ extern crate actix_web; extern crate clap; use clap::{Arg}; -use actix_web::{server, App}; +use actix_web::{server, App, http}; mod controllers; @@ -30,7 +30,9 @@ fn main() { } println!("[rustyhub] Starting server"); - server::new(|| App::new().resource("/", |r| r.f(controllers::index))) + server::new(|| App::new() + .route("/", http::Method::GET, controllers::index) + .route("/", http::Method::POST, controllers::hub)) .bind(format!("{}:{}", address, port)) .unwrap() .run();