diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2020-06-03 23:26:24 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2020-06-03 23:26:24 -0400 |
| commit | 21de322d6cf221867ec9600e1a31777a195c7597 (patch) | |
| tree | 1aab43a7559daa252cd1412a9bc2f8e3f367fe33 /src/main.rs | |
| parent | 23687bea794a18ff594658e9006457bff7b4a752 (diff) | |
| parent | ebd04ae88f28a547eabbb44e1eccfd19965be7ae (diff) | |
Replace Python (apistar) version with Rust (actix-web) version.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8faebd4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,38 @@ +#![feature(proc_macro_hygiene)] + +use actix_web::{App, HttpServer}; +use std::io; +use thiserror::Error; + +mod twelve; +mod view; + +#[derive(Error, Debug)] +pub enum Error { + #[error("Unable to determine port number: {0}")] + PortError(#[from] twelve::Error), + #[error("Unable to initialize web view: {0}")] + ViewError(#[from] view::Error), + #[error("Unexpected IO error: {0}")] + IOError(#[from] io::Error), +} + +type Result = std::result::Result<(), Error>; + +#[actix_rt::main] +async fn main() -> Result { + let port = twelve::port(3000)?; + + let service = view::make_service()?; + + let app_factory = move || + App::new() + .configure(|cfg| service(cfg)); + + HttpServer::new(app_factory) + .bind(port)? + .run() + .await?; + + Ok(()) +} |
