diff options
| author | Fuwn <[email protected]> | 2022-03-09 18:55:39 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-09 18:55:39 -0800 |
| commit | d61504fd0f7cdc2eb9d315ea5450c773098e209a (patch) | |
| tree | e750f545868d804c1b7ed11d81f0f814c549492d | |
| parent | format(readme): case (diff) | |
| download | api-worker-d61504fd0f7cdc2eb9d315ea5450c773098e209a.tar.xz api-worker-d61504fd0f7cdc2eb9d315ea5450c773098e209a.zip | |
feat(index): git commit hash on index
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/constants.rs | 28 | ||||
| -rw-r--r-- | src/index.rst | 2 | ||||
| -rw-r--r-- | src/routes.rs | 2 |
4 files changed, 29 insertions, 5 deletions
@@ -40,6 +40,8 @@ worker = "0.0.9" # Utility cfg-if = "1.0.0" +const_format = "0.2.22" +lazy_static = "1.4.0" # Web reqwest = { version = "0.11.9", features = ["json"] } diff --git a/src/constants.rs b/src/constants.rs index 003fdf1..b5fb1e0 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -16,7 +16,27 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only -pub const GITHUB_USER_CONTENT: &str = - "https://raw.githubusercontent.com/laynH/Anime-Girls-Holding-Programming-Books/master/"; -pub const GITHUB_API_ENDPOINT: &str = "https://api.github.com/repos/laynH/Anime-Girls-Holding-Progr\ -amming-Books/git/trees/master?recursive=1"; +use const_format::formatcp; + +lazy_static::lazy_static! { + pub static ref INDEX: String = { + format!( + include_str!("index.rst"), + format_args!( + "https://github.com/senpy-club/api-worker/tree/{}", + env!("GIT_COMMIT_HASH"), + ) + ) + }; +} + +const GITHUB_REPOSITORY: &str = + "cat-milk/Anime-Girls-Holding-Programming-Books"; +pub const GITHUB_USER_CONTENT: &str = formatcp!( + "https://raw.githubusercontent.com/{}/master/", + GITHUB_REPOSITORY +); +pub const GITHUB_API_ENDPOINT: &str = formatcp!( + "https://api.github.com/repos/{}/git/trees/master?recursive=1", + GITHUB_REPOSITORY, +); diff --git a/src/index.rst b/src/index.rst index 145cf4c..c9c00b0 100644 --- a/src/index.rst +++ b/src/index.rst @@ -1,6 +1,8 @@ api.senpy.club ============== +This API is on commit {}. + Routes ------ diff --git a/src/routes.rs b/src/routes.rs index 2bade5d..9e4767a 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -25,7 +25,7 @@ use crate::{ }; pub fn index() -> Result<Response> { - Response::ok(include_str!("index.rst"))?.with_cors(&cors()) + Response::ok(&*crate::constants::INDEX)?.with_cors(&cors()) } pub async fn github() -> Result<Response> { |