2018-06-06 03:32:40 +02:00
|
|
|
extern crate actix_web;
|
2018-07-19 01:57:00 +02:00
|
|
|
extern crate clap;
|
|
|
|
use clap::{Arg};
|
2019-03-24 21:17:55 +01:00
|
|
|
use actix_web::{server, App};
|
2018-06-06 03:32:40 +02:00
|
|
|
|
2019-03-24 21:17:55 +01:00
|
|
|
mod controllers;
|
2018-06-06 03:32:40 +02:00
|
|
|
|
2018-06-05 02:22:33 +02:00
|
|
|
fn main() {
|
2018-07-19 01:57:00 +02:00
|
|
|
println!("[rustyhub] Launching hub");
|
|
|
|
let matches = clap::App::new("Rusty Hub")
|
|
|
|
.version("0.1.0")
|
|
|
|
.author("Gonçalo Valério <gon@ovalerio.net>")
|
|
|
|
.about("Runs a simple and compliant websub hub")
|
|
|
|
.arg(Arg::with_name("config")
|
|
|
|
.short("c")
|
|
|
|
.long("config")
|
|
|
|
.value_name("FILE")
|
|
|
|
.help("Sets a custom config file")
|
|
|
|
.takes_value(true))
|
|
|
|
.get_matches();
|
|
|
|
|
|
|
|
let address = "127.0.0.1";
|
|
|
|
let port = "8888";
|
|
|
|
|
|
|
|
println!("[rustyhub] Loading configuration");
|
|
|
|
let config = matches.value_of("config").unwrap_or("");
|
|
|
|
if !config.is_empty() {
|
|
|
|
println!("Not implemented");
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("[rustyhub] Starting server");
|
2019-03-24 21:17:55 +01:00
|
|
|
server::new(|| App::new().resource("/", |r| r.f(controllers::index)))
|
2018-07-19 01:57:00 +02:00
|
|
|
.bind(format!("{}:{}", address, port))
|
2018-06-06 03:32:40 +02:00
|
|
|
.unwrap()
|
|
|
|
.run();
|
2018-07-19 01:57:00 +02:00
|
|
|
println!("[rustyhub] Shutting down server");
|
2018-06-05 02:22:33 +02:00
|
|
|
}
|