mirror of https://github.com/raftario/filite.git
main
This commit is contained in:
parent
bb4366100f
commit
95a2495b5b
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue