From 0d107609b36d8878adda77274d10ac81607277d9 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Fri, 16 Sep 2022 17:39:37 +0530 Subject: [PATCH] feat: mv routes into main and extract serve from api services --- src/api/v1/mod.rs | 1 - src/main.rs | 36 +++++++++++------------------------- src/page.rs | 3 ++- src/routes.rs | 17 ----------------- src/tests.rs | 2 +- 5 files changed, 14 insertions(+), 45 deletions(-) delete mode 100644 src/routes.rs diff --git a/src/api/v1/mod.rs b/src/api/v1/mod.rs index 6d891c0..301d201 100644 --- a/src/api/v1/mod.rs +++ b/src/api/v1/mod.rs @@ -29,7 +29,6 @@ pub fn services(cfg: &mut ServiceConfig) { account::services(cfg); crate::meta::services(cfg); crate::deploy::services(cfg); - crate::serve::services(cfg); } #[derive(Deserialize)] diff --git a/src/main.rs b/src/main.rs index 7a73ff6..672fe8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use actix_web::{ }; use clap::{Parser, Subcommand}; use log::info; +use static_assets::FileMap; mod api; mod ctx; @@ -32,16 +33,17 @@ mod errors; mod git; mod meta; mod page; +mod pages; mod preview; -mod routes; mod serve; mod settings; +mod static_assets; #[cfg(test)] mod tests; mod utils; +pub use crate::api::v1::ROUTES as V1_API_ROUTES; use ctx::Ctx; -pub use routes::ROUTES as V1_API_ROUTES; pub use settings::Settings; pub const CACHE_AGE: u32 = 604800; @@ -54,28 +56,9 @@ pub const PKG_HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE"); pub type AppCtx = WebData; -//#[cfg(not(tarpaulin_include))] -//#[actix_web::main] -//async fn main() -> std::io::Result<()> { -// { -// const LOG_VAR: &str = "RUST_LOG"; -// if env::var(LOG_VAR).is_err() { -// env::set_var("RUST_LOG", "info"); -// } -// } -// -// let settings = Settings::new().unwrap(); -// let ctx = WebData::new(ctx::Ctx::new(settings.clone())); -// -// pretty_env_logger::init(); -// -// info!( -// "{}: {}.\nFor more information, see: {}\nBuild info:\nVersion: {} commit: {}", -// PKG_NAME, PKG_DESCRIPTION, PKG_HOMEPAGE, VERSION, GIT_COMMIT_HASH -// ); -// -// -//} +lazy_static::lazy_static! { + pub static ref FILES: FileMap = FileMap::new(); +} #[derive(Parser)] #[clap(author, version, about, long_about = None)] @@ -168,5 +151,8 @@ pub fn get_identity_service(settings: &Settings) -> IdentityService - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -pub use crate::api::v1::{routes::ROUTES, services}; diff --git a/src/tests.rs b/src/tests.rs index fd3d420..27bf4f3 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -132,7 +132,7 @@ macro_rules! get_app { .wrap(actix_web::middleware::NormalizePath::new( actix_web::middleware::TrailingSlash::Trim, )) - .configure($crate::routes::services) + .configure($crate::services) .app_data($crate::WebData::new($ctx.clone())), ) };