From 53f491cdcc527f85be3069e921a41264e32919f0 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 23 May 2023 10:04:02 +0200 Subject: [PATCH] add API /love --- src/main.rs | 4 +++- src/routes/api_v1.rs | 14 ++++++++++++++ src/routes/mod.rs | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/routes/api_v1.rs diff --git a/src/main.rs b/src/main.rs index b20b71b..573e5d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,8 @@ use actix_web::{middleware::DefaultHeaders, web, App, HttpServer}; use std::io::Result; use crate::routes::{ - agreements, blog, contrib, cours, cv, gaming, index, networks, not_found, portfolio, web3, + agreements, api_v1, blog, contrib, cours, cv, gaming, index, networks, not_found, portfolio, + web3, }; mod config; @@ -32,6 +33,7 @@ async fn main() -> Result<()> { "Onion-Location", config.fc.onion.as_deref().unwrap_or_default(), ))) + .service(web::scope("/api").service(web::scope("v1").service(api_v1::love))) .service(index::page) .service(agreements::security) .service(agreements::humans) diff --git a/src/routes/api_v1.rs b/src/routes/api_v1.rs new file mode 100644 index 0000000..e56c0ef --- /dev/null +++ b/src/routes/api_v1.rs @@ -0,0 +1,14 @@ +use actix_web::{get, HttpResponse, Responder}; +use serde::Serialize; + +#[derive(Serialize)] +struct Info { + unix_epoch: u32, +} + +#[get("/love")] +pub async fn love() -> impl Responder { + HttpResponse::Ok().json(Info { + unix_epoch: 1605576600, + }) +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs index f10dfb9..8d3a6d5 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,4 +1,5 @@ pub mod agreements; +pub mod api_v1; pub mod blog; pub mod contrib; pub mod cours;