GitLab CI + v3 Endpoint #1
This commit is contained in:
parent
e19187d6c7
commit
790a7dd8ee
4 changed files with 331 additions and 1 deletions
src
28
src/main.rs
28
src/main.rs
|
@ -12,6 +12,7 @@ use crate::db::connect_postgres;
|
|||
|
||||
mod db;
|
||||
mod v2;
|
||||
mod v3;
|
||||
|
||||
macro_rules! api_base {
|
||||
() => {
|
||||
|
@ -75,6 +76,15 @@ async fn postgres_watchdog(pool: PgPool, is_alive: Arc<AtomicBool>, shutdown: Ar
|
|||
};
|
||||
|
||||
let passed = (Local::now() - start).to_std().expect(&format!("Unable to get Time Difference for '{}' and '{}'", start, Local::now()));
|
||||
|
||||
thread::sleep(Duration::from_secs(5) - passed);
|
||||
if shutdown.load(Ordering::Relaxed) {
|
||||
break;
|
||||
}
|
||||
thread::sleep(Duration::from_secs(10) - passed);
|
||||
if shutdown.load(Ordering::Relaxed) {
|
||||
break;
|
||||
}
|
||||
thread::sleep(Duration::from_secs(15) - passed);
|
||||
}
|
||||
is_alive.store(false, Ordering::Relaxed);
|
||||
|
@ -121,7 +131,21 @@ async fn main() -> Result<()> {
|
|||
struct ApiDocV2;
|
||||
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(paths(), components(schemas()))]
|
||||
#[openapi(
|
||||
paths(
|
||||
v3::full_view_data,
|
||||
),
|
||||
components(schemas(
|
||||
v3::schemas::FullViewData,
|
||||
v3::schemas::Ethic,
|
||||
v3::schemas::EmpireEthic,
|
||||
v3::schemas::ChellarisGame,
|
||||
v3::schemas::Species,
|
||||
v3::schemas::ChellarisGameGroup,
|
||||
v3::schemas::Portrait,
|
||||
v3::schemas::ChellarisEmpire
|
||||
))
|
||||
)]
|
||||
struct ApiDocV3;
|
||||
|
||||
let openapi_urls = vec![
|
||||
|
@ -156,6 +180,8 @@ async fn main() -> Result<()> {
|
|||
.service(v2::games)
|
||||
.service(v2::portrait_groups)
|
||||
.service(v2::portraits)
|
||||
// API v3 Endpoints
|
||||
.service(v3::full_view_data)
|
||||
// Swagger UI
|
||||
.service(
|
||||
SwaggerUi::new(concat!(api_base!(), "/swagger/{_:.*}"))
|
||||
|
|
Reference in a new issue