added post route for the hub functionality

This commit is contained in:
Gonçalo Valério 2019-03-30 22:49:47 +00:00
parent f66a16c34c
commit 5d6243ae26
2 changed files with 10 additions and 4 deletions

View File

@ -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)]

View File

@ -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();