This commit is contained in:
Raphaël Thériault 2020-10-01 13:18:41 -04:00
parent bb4366100f
commit 95a2495b5b
No known key found for this signature in database
GPG Key ID: D4E92B68275D389F
2 changed files with 3 additions and 6 deletions

View File

@ -11,6 +11,7 @@ mod tests;
use anyhow::Error;
use config::Config;
use sled::Db;
use structopt::StructOpt;
use tracing_subscriber::fmt::format::FmtSpan;
use warp::{Filter, Reply};
@ -57,15 +58,11 @@ fn main() -> Result<(), Error> {
let db = db::connect(&config.database)?;
let mut runtime = runtime::build(&config.runtime)?;
runtime.block_on(run(config))?;
runtime.block_on(serve(routes::handler(config, db), config));
Ok(())
}
async fn run(config: &'static Config) -> Result<(), Error> {
Ok(())
}
async fn serve(
filter: impl Filter<Extract = (impl Reply,)> + Send + Sync + Clone + 'static,
config: &Config,

View File

@ -6,7 +6,7 @@ use warp::{http::Uri, Filter, Rejection, Reply};
pub fn handler(
config: &'static Config,
db: &'static Db,
) -> impl Filter<Extract = impl Reply, Error = Rejection> + Copy + Send + Sync + 'static {
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Copy + Send + Sync + 'static {
let filite = warp::path!(String)
.and(warp::get())
.and_then(move |id| filite(id, db));