feat: mv routes into main and extract serve from api services
This commit is contained in:
parent
1ada27924e
commit
0d107609b3
5 changed files with 14 additions and 45 deletions
|
@ -29,7 +29,6 @@ pub fn services(cfg: &mut ServiceConfig) {
|
||||||
account::services(cfg);
|
account::services(cfg);
|
||||||
crate::meta::services(cfg);
|
crate::meta::services(cfg);
|
||||||
crate::deploy::services(cfg);
|
crate::deploy::services(cfg);
|
||||||
crate::serve::services(cfg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -23,6 +23,7 @@ use actix_web::{
|
||||||
};
|
};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use log::info;
|
use log::info;
|
||||||
|
use static_assets::FileMap;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod ctx;
|
mod ctx;
|
||||||
|
@ -32,16 +33,17 @@ mod errors;
|
||||||
mod git;
|
mod git;
|
||||||
mod meta;
|
mod meta;
|
||||||
mod page;
|
mod page;
|
||||||
|
mod pages;
|
||||||
mod preview;
|
mod preview;
|
||||||
mod routes;
|
|
||||||
mod serve;
|
mod serve;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
mod static_assets;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
pub use crate::api::v1::ROUTES as V1_API_ROUTES;
|
||||||
use ctx::Ctx;
|
use ctx::Ctx;
|
||||||
pub use routes::ROUTES as V1_API_ROUTES;
|
|
||||||
pub use settings::Settings;
|
pub use settings::Settings;
|
||||||
|
|
||||||
pub const CACHE_AGE: u32 = 604800;
|
pub const CACHE_AGE: u32 = 604800;
|
||||||
|
@ -54,28 +56,9 @@ pub const PKG_HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
|
||||||
|
|
||||||
pub type AppCtx = WebData<ctx::ArcCtx>;
|
pub type AppCtx = WebData<ctx::ArcCtx>;
|
||||||
|
|
||||||
//#[cfg(not(tarpaulin_include))]
|
lazy_static::lazy_static! {
|
||||||
//#[actix_web::main]
|
pub static ref FILES: FileMap = FileMap::new();
|
||||||
//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
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[clap(author, version, about, long_about = None)]
|
||||||
|
@ -168,5 +151,8 @@ pub fn get_identity_service(settings: &Settings) -> IdentityService<CookieIdenti
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||||
routes::services(cfg);
|
crate::api::v1::services(cfg);
|
||||||
|
crate::pages::services(cfg);
|
||||||
|
crate::static_assets::services(cfg);
|
||||||
|
crate::serve::services(cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,11 @@ use log::info;
|
||||||
use std::println as info;
|
use std::println as info;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Deserialize)]
|
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
pub secret: String,
|
pub secret: String,
|
||||||
pub repo: String,
|
pub repo: String,
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
|
||||||
*
|
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
pub use crate::api::v1::{routes::ROUTES, services};
|
|
|
@ -132,7 +132,7 @@ macro_rules! get_app {
|
||||||
.wrap(actix_web::middleware::NormalizePath::new(
|
.wrap(actix_web::middleware::NormalizePath::new(
|
||||||
actix_web::middleware::TrailingSlash::Trim,
|
actix_web::middleware::TrailingSlash::Trim,
|
||||||
))
|
))
|
||||||
.configure($crate::routes::services)
|
.configure($crate::services)
|
||||||
.app_data($crate::WebData::new($ctx.clone())),
|
.app_data($crate::WebData::new($ctx.clone())),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue