mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Create basic CDN endpoints for #10
This commit is contained in:
8
cdn/src/robocraft/brawl_data.rs
Normal file
8
cdn/src/robocraft/brawl_data.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
|
||||
|
||||
#[get("/brawldata/Live/{name}")]
|
||||
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
|
||||
let path = std::path::PathBuf::from(&cli.data_robocraft).join("brawldata").join(format!("{}.jpg", name.path()));
|
||||
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
|
||||
actix_files::NamedFile::open_async(path).await
|
||||
}
|
||||
8
cdn/src/robocraft/campaign_data.rs
Normal file
8
cdn/src/robocraft/campaign_data.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
|
||||
|
||||
#[get("/campaigndata/Live/{name}")]
|
||||
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
|
||||
let path = std::path::PathBuf::from(&cli.data_robocraft).join("campaigndata").join(format!("{}.jpg", name.path()));
|
||||
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
|
||||
actix_files::NamedFile::open_async(path).await
|
||||
}
|
||||
8
cdn/src/robocraft/clan_avatar.rs
Normal file
8
cdn/src/robocraft/clan_avatar.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
|
||||
|
||||
#[get("/clanavatar/Live/{name}")]
|
||||
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
|
||||
let path = std::path::PathBuf::from(&cli.data_robocraft).join("clanavatar").join(format!("{}.jpg", name.path()));
|
||||
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
|
||||
actix_files::NamedFile::open_async(path).await
|
||||
}
|
||||
@@ -3,5 +3,6 @@ use actix_web::{get, Responder, web::Data};
|
||||
#[get("/live/data.json")]
|
||||
pub async fn live_data_json(cli: Data<crate::cli::CliArgs>) -> impl Responder {
|
||||
let path = std::path::PathBuf::from(&cli.assets_robocraft).join("live_data.json");
|
||||
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
|
||||
actix_files::NamedFile::open_async(path).await
|
||||
}
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
pub mod live_data;
|
||||
pub mod user_avatar;
|
||||
pub mod clan_avatar;
|
||||
pub mod brawl_data;
|
||||
pub mod campaign_data;
|
||||
|
||||
8
cdn/src/robocraft/user_avatar.rs
Normal file
8
cdn/src/robocraft/user_avatar.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use actix_web::{dev::ResourcePath, get, web::{Data, Path}, Responder};
|
||||
|
||||
#[get("/customavatar/Live/{name}")]
|
||||
pub async fn get(cli: Data<crate::cli::CliArgs>, name: Path<String>) -> impl Responder {
|
||||
let path = std::path::PathBuf::from(&cli.data_robocraft).join("customavatars").join(format!("{}.jpg", name.path()));
|
||||
log::debug!("RC asset at {} (exists? {})", path.display(), path.exists());
|
||||
actix_files::NamedFile::open_async(path).await
|
||||
}
|
||||
Reference in New Issue
Block a user