Add /api/{alive,now,version} endpoints

The added endpoints work the same as in their upstream implementations.

Upstream also implements `/api/ip`. This seems to include the server's public
IP address (the one that should be hidden behind Cloudflare), which doesn't
seem like a great idea.
This commit is contained in:
Jeremy Lin
2022-04-23 23:47:49 -07:00
parent 26ad06df7c
commit df8aeb10e8
2 changed files with 26 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ use rocket::{fs::NamedFile, http::ContentType, Route};
use serde_json::Value;
use crate::{
api::core::now,
error::Error,
util::{Cached, SafeString},
CONFIG,
@@ -71,10 +72,7 @@ async fn attachments(uuid: SafeString, file_id: SafeString) -> Option<NamedFile>
use crate::db::DbConn;
#[get("/alive")]
fn alive(_conn: DbConn) -> Json<String> {
use crate::util::format_date;
use chrono::Utc;
Json(format_date(&Utc::now().naive_utc()))
now()
}
#[get("/vw_static/<filename>")]