From a1959e502f2d730c021251d6a625f9ab6ab15d92 Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Wed, 17 Jan 2024 00:04:51 +0900 Subject: [PATCH] feat(http/sitemaps): implement `sitemaps` mock endpoint --- README.md | 2 +- src/main.rs | 2 ++ src/resources/sitemaps/index.json | 46 +++++++++++++++++++++++++++++++ src/services.rs | 1 + src/services/sitemaps.rs | 8 ++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/resources/sitemaps/index.json create mode 100644 src/services/sitemaps.rs diff --git a/README.md b/README.md index 5bb2564..2e485f6 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Please see [Qualtet's REST API docs](https://yoshinorin.github.io/qualtet/rest-a - [ ] `/search` - [x] `/series` - [ ] `/series/{seriesName}` -- [ ] `/sitemaps` +- [x] `/sitemaps/` - [x] `/system/health` - [x] `/system/metadata` - [x] `/tags` diff --git a/src/main.rs b/src/main.rs index fb8099e..5ddca28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use services::{ contents::{content_with_trailing_slash, content_without_trailing_slash}, index::index, series::series, + sitemaps::sitemaps, system::{health, metadata}, tags::{tag_a, tags}, }; @@ -33,6 +34,7 @@ async fn main() -> std::io::Result<()> { .service(content_with_trailing_slash) .service(content_without_trailing_slash) .service(series) + .service(sitemaps) .service(health) .service(metadata) .service(tags) diff --git a/src/resources/sitemaps/index.json b/src/resources/sitemaps/index.json new file mode 100644 index 0000000..2e84808 --- /dev/null +++ b/src/resources/sitemaps/index.json @@ -0,0 +1,46 @@ +[ + { + "loc": "/articles/nested/standard/", + "lastMod": "2023-12-27" + }, + { + "loc": "/articles/nested/empty-robots/", + "lastMod": "2023-12-26" + }, + { + "loc": "/articles/nested/empty-tags/", + "lastMod": "2023-12-25" + }, + { + "loc": "/articles/2016/07/13/csharp-file-hash-value/", + "lastMod": "2023-12-13" + }, + { + "loc": "/articles/nested/partially-robots/", + "lastMod": "2023-12-12" + }, + { + "loc": "/articles/nested/with-externalresources/", + "lastMod": "2023-12-11" + }, + { + "loc": "/articles/nested/without-robots/", + "lastMod": "2023-12-10" + }, + { + "loc": "/articles/nested/without-tags/", + "lastMod": "2023-12-09" + }, + { + "loc": "/articles/2023/12/08/gravida/", + "lastMod": "2023-12-08" + }, + { + "loc": "/articles/2023/12/07/vestibulum/", + "lastMod": "2023-12-07" + }, + { + "loc": "/articles/2023/12/06/sodales/", + "lastMod": "2023-12-06" + } +] diff --git a/src/services.rs b/src/services.rs index 0b5bdbe..4fbf09a 100644 --- a/src/services.rs +++ b/src/services.rs @@ -3,5 +3,6 @@ pub mod articles; pub mod contents; pub mod index; pub mod series; +pub mod sitemaps; pub mod system; pub mod tags; diff --git a/src/services/sitemaps.rs b/src/services/sitemaps.rs new file mode 100644 index 0000000..dcd0c96 --- /dev/null +++ b/src/services/sitemaps.rs @@ -0,0 +1,8 @@ +use crate::utils; +use actix_web::{get, Error, HttpResponse}; + +#[get("/sitemaps/")] +pub async fn sitemaps() -> Result { + let content = utils::readfile("./src/resources/sitemaps/index.json")?; + utils::make_ok_response(content) +}