Adding some simple tide scaffolding
This commit is contained in:
parent
e25b287be7
commit
983c9d0f47
11
Cargo.toml
11
Cargo.toml
|
@ -2,7 +2,14 @@
|
||||||
name = "geoffrey"
|
name = "geoffrey"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
authors = ["R Tyler Croy <rtyler@brokenco.de>"]
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
description = "The freshest butler in Bel-air"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
async-std = { version = "1", features = ["attributes", "tokio1"] }
|
||||||
|
dotenv = "*"
|
||||||
|
handlebars = { version = "4", features = ["dir_source"] }
|
||||||
|
log = "*"
|
||||||
|
pretty_env_logger = "0.3"
|
||||||
|
#sqlx = { version = "0.5", features = ["chrono", "json", "offline", "postgres", "uuid", "runtime-async-std-rustls"] }
|
||||||
|
tide = "*"
|
||||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -1,3 +1,29 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
|
#[async_std::main]
|
||||||
|
async fn main() -> Result<(), std::io::Error> {
|
||||||
|
dotenv::dotenv().ok();
|
||||||
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
info!("Activating DEBUG mode configuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(fd) = std::env::var("LISTEN_FD")
|
||||||
|
.ok()
|
||||||
|
.and_then(|fd| fd.parse().ok())
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Allow the use of catflag for local development
|
||||||
|
* <https://github.com/passcod/catflap>
|
||||||
|
*/
|
||||||
|
use std::net::TcpListener;
|
||||||
|
use std::os::unix::io::FromRawFd;
|
||||||
|
app.listen(unsafe { TcpListener::from_raw_fd(fd) }).await?;
|
||||||
|
} else {
|
||||||
|
app.listen("0.0.0.0:8000").await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue