From eddc15883aabe2ccd5652f804bb0d3fb01dbc334 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Thu, 4 Jun 2020 01:04:08 -0400 Subject: Renamed primary binary to `web`. This closely matches Procfile entries, making the structure of the project a little easier to follow. --- src/bin/web.rs | 36 ++++++++++++++++++++++++++++++++++++ src/lib.rs | 4 ++++ src/main.rs | 38 -------------------------------------- 3 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 src/bin/web.rs create mode 100644 src/lib.rs delete mode 100644 src/main.rs (limited to 'src') diff --git a/src/bin/web.rs b/src/bin/web.rs new file mode 100644 index 0000000..3186207 --- /dev/null +++ b/src/bin/web.rs @@ -0,0 +1,36 @@ +use actix_web::{App, HttpServer}; +use std::io; +use thiserror::Error; + +use things_to_check::twelve; +use things_to_check::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(()) +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..eb1da51 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,4 @@ +#![feature(proc_macro_hygiene)] + +pub mod twelve; +pub mod view; diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 8faebd4..0000000 --- a/src/main.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![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(()) -} -- cgit v1.2.3