summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2020-06-04 01:04:08 -0400
committerOwen Jacobson <owen@grimoire.ca>2020-06-04 01:04:08 -0400
commiteddc15883aabe2ccd5652f804bb0d3fb01dbc334 (patch)
treef90050a98312a3c5e641debf65b7b8b17ba740c8 /src/bin
parente0aeb8aa134bd7fe93526a32b004e77b267a3ba2 (diff)
Renamed primary binary to `web`.
This closely matches Procfile entries, making the structure of the project a little easier to follow.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/web.rs36
1 files changed, 36 insertions, 0 deletions
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(())
+}