38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
use std::net::SocketAddr;
|
|
use actix_web::{App, web, HttpServer};
|
|
use clap::Parser;
|
|
|
|
mod app;
|
|
mod handlers;
|
|
mod models;
|
|
mod templates;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(author, version, about, long_about = None)]
|
|
struct CLIArgs {
|
|
#[arg(short, long)]
|
|
bind: String
|
|
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
let args = CLIArgs::parse();
|
|
let addr: SocketAddr = args.bind.parse().expect(&format!("Cannot bind to {}. Please provide a host and port like [::1]:8000", &args.bind));
|
|
|
|
println!("Server listening to {}", &args.bind);
|
|
|
|
HttpServer::new(
|
|
|| {
|
|
let state = models::AppState::new();
|
|
App::new().app_data(web::Data::new(state))
|
|
.route("/", web::get().to(handlers::landing_page))
|
|
.route("/account/register-init", web::post().to(handlers::start_webauthn_registration))
|
|
.route("/account/register-finish", web::post().to(handlers::finish_webauthn_registration))
|
|
})
|
|
.bind(addr)
|
|
.unwrap()
|
|
.run()
|
|
.await
|
|
}
|