merge
All checks were successful
Build and Test / account (push) Successful in 6m46s

This commit is contained in:
Maple 2026-04-27 14:29:13 +02:00
commit c06afde7cb
4 changed files with 54 additions and 19 deletions

View file

@ -116,8 +116,8 @@ async fn launch() -> _ {
EmptySubscription::new())
)
.attach(AdHoc::on_response("org", |_, response| Box::pin(async move {
//response.adjoin_header(Header::new("x-organization", "Nintendo"));
response.adjoin_header(Header::new("x-nintendo-date", SystemTime::now()
response.adjoin_header(Header::new("x-organization", "Nintendo"));
response.adjoin_header(Header::new("X-Nintendo-Date", SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis()

View file

@ -2,6 +2,12 @@ use rocket::{get, State};
use serde::Serialize;
use crate::Pool;
use crate::xml::Xml;
use std::io::Cursor;
use rocket::{Request, response::{Responder, Response}};
use rocket::http::Header;
use time::{OffsetDateTime, Time};
use time::format_description::well_known::Rfc2822;
#[derive(Serialize)]
#[serde(rename = "mapped_id")]
@ -21,6 +27,23 @@ struct UserIdAndName {
username: String,
}
pub struct TimeResponse;
#[rocket::async_trait]
impl<'r> Responder<'r, 'static> for TimeResponse {
fn respond_to(self, _req: &'r Request<'_>) -> rocket::response::Result<'static> {
let now = OffsetDateTime::now_utc()
.format(&Rfc2822)
.unwrap()
.replace("+0000", "GMT");
Response::build()
.header(Header::new("Date", now))
.sized_body(0, Cursor::new(""))
.ok()
}
}
#[get("/v1/api/admin/mapped_ids?<input_type>&<output_type>&<input>")]
pub async fn mapped_ids(pool: &State<Pool>, input_type: String, output_type: String, input: String) -> Option<Xml<MappedIds>> {
let pool = pool.inner();
@ -83,6 +106,6 @@ pub async fn mapped_ids(pool: &State<Pool>, input_type: String, output_type: Str
}
#[get("/v1/api/admin/time")]
pub fn get_time() {
// stubbed, it only needs the header.
pub fn get_time() -> TimeResponse {
TimeResponse
}