Skip to content

Commit

Permalink
add logo.png storing
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Feb 17, 2024
1 parent 02c954b commit badbb78
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 8 deletions.
197 changes: 197 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
image = { version = "0.24.8", features = ["png"] }
actix-web = "4.4.1"
anyhow = "1.0.78"
dotenvy = "0.15.7"
Expand All @@ -12,10 +13,16 @@ log = "0.4.20"
futures = "0.3.30"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0"
sqlx = { version = "0.7.3", features = ["postgres", "runtime-tokio", "chrono", "uuid", "ipnetwork"] }
sqlx = { version = "0.7.3", features = [
"postgres",
"runtime-tokio",
"chrono",
"uuid",
"ipnetwork",
] }
tokio = { version = "1.35.1", features = ["rt", "macros", "rt-multi-thread"] }
reqwest = { version = "0.11.23", features = ["json"]}
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics"]}
reqwest = { version = "0.11.23", features = ["json"] }
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics"] }
zip = "0.6"
sha256 = "1.5.0"
semver = "1.0.21"
semver = "1.0.21"
14 changes: 14 additions & 0 deletions src/endpoints/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,17 @@ pub async fn create(
}
Ok(HttpResponse::NoContent())
}

#[get("/v1/mods/{id}/logo")]
pub async fn get_logo(
data: web::Data<AppData>,
path: web::Path<String>,
) -> Result<impl Responder, ApiError> {
let mut pool = data.db.acquire().await.or(Err(ApiError::DbAcquireError))?;
let image = Mod::get_logo_for_mod(&path, &mut pool).await?;

match image {
Some(i) => Ok(HttpResponse::Ok().content_type("image/png").body(i)),
None => Err(ApiError::NotFound("".into())),
}
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async fn main() -> anyhow::Result<()> {
.service(endpoints::mods::index)
.service(endpoints::mods::get)
.service(endpoints::mods::create)
.service(endpoints::mods::get_logo)
.service(endpoints::mod_versions::get_one)
.service(endpoints::mod_versions::download_version)
.service(endpoints::mod_versions::create_version)
Expand Down
Loading

0 comments on commit badbb78

Please sign in to comment.