2018-06-06 03:32:40 +02:00
|
|
|
extern crate actix_web;
|
2019-03-31 20:14:56 +02:00
|
|
|
extern crate askama;
|
2018-07-19 01:57:00 +02:00
|
|
|
extern crate clap;
|
|
|
|
use clap::{Arg};
|
2019-03-30 23:49:47 +01:00
|
|
|
use actix_web::{server, App, http};
|
2019-03-31 20:14:56 +02:00
|
|
|
use controllers::{index, hub};
|
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-30 23:49:47 +01:00
|
|
|
server::new(|| App::new()
|
2019-03-31 20:14:56 +02:00
|
|
|
.route("/", http::Method::GET, index)
|
|
|
|
.route("/", http::Method::POST, hub))
|
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
|
|
|
}
|