start adding basic app modules
This commit is contained in:
parent
edf4888534
commit
778bd133e8
|
@ -332,6 +332,15 @@ dependencies = [
|
|||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "envy"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f938a4abd5b75fe3737902dbc2e79ca142cc1526827a9e40b829a086758531a9"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
|
@ -2160,14 +2169,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "xesite"
|
||||
version = "0.1.0"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"comrak",
|
||||
"envy",
|
||||
"handlebars",
|
||||
"log 0.4.8",
|
||||
"log 0.3.9",
|
||||
"pretty_env_logger",
|
||||
"rand 0.7.3",
|
||||
"rand 0.6.5",
|
||||
"serde",
|
||||
"serde_dhall",
|
||||
"tokio",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "xesite"
|
||||
version = "0.1.0"
|
||||
version = "2.0.0"
|
||||
authors = ["Christine Dodrill <me@christine.website>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -9,6 +9,7 @@ edition = "2018"
|
|||
[dependencies]
|
||||
anyhow = "1"
|
||||
comrak = "0.7"
|
||||
envy = "0.4"
|
||||
handlebars = "3.2.1"
|
||||
log = "0"
|
||||
pretty_env_logger = "0"
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
use crate::signalboost::Person;
|
||||
use anyhow::Result;
|
||||
use serde::Deserialize;
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod defaults {
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn clacks() -> Vec<String> {
|
||||
vec!["Ashlynn".to_string()]
|
||||
}
|
||||
|
||||
pub fn signalboost_fname() -> PathBuf {
|
||||
"./signalboost.dhall".into()
|
||||
}
|
||||
pub fn port() -> u16 {
|
||||
34252
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct Config {
|
||||
#[serde(default = "defaults::clacks")]
|
||||
clack_set: Vec<String>,
|
||||
#[serde(default = "defaults::signalboost_fname")]
|
||||
signalboost_fname: PathBuf,
|
||||
#[serde(default = "defaults::port")]
|
||||
port: u16,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct State {
|
||||
pub cfg: Config,
|
||||
pub signalboost: Vec<Person>,
|
||||
}
|
||||
|
||||
pub fn init<'a>() -> Result<State> {
|
||||
let cfg: Config = envy::from_env()?;
|
||||
let sb = serde_dhall::from_file(cfg.signalboost_fname.clone()).parse()?;
|
||||
|
||||
Ok(State {
|
||||
cfg: cfg,
|
||||
signalboost: sb,
|
||||
})
|
||||
}
|
24
src/main.rs
24
src/main.rs
|
@ -1,3 +1,23 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use anyhow::Result;
|
||||
use warp::Filter;
|
||||
|
||||
pub mod app;
|
||||
pub mod signalboost;
|
||||
|
||||
const APPLICATION_NAME: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
pretty_env_logger::init();
|
||||
|
||||
let state = app::init()?;
|
||||
|
||||
// GET /hello/warp => 200 OK with body "Hello, warp!"
|
||||
let hello = warp::path!("hello" / String).map(|name| format!("Hello, {}!", name));
|
||||
|
||||
warp::serve(hello.with(warp::log(APPLICATION_NAME)))
|
||||
.run(([127, 0, 0, 1], 3030))
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct Person {
|
||||
pub name: String,
|
||||
pub tags: Vec<String>,
|
||||
|
||||
#[serde(rename = "gitLink")]
|
||||
pub git_link: String,
|
||||
|
||||
pub twitter: String,
|
||||
}
|
Loading…
Reference in New Issue