mirror of
https://github.com/actix/examples
synced 2025-04-22 08:34:52 +02:00
build: updated from main
This commit is contained in:
parent
661438af4a
commit
dbea1221d8
36
Cargo.lock
generated
36
Cargo.lock
generated
@ -2640,7 +2640,7 @@ version = "1.0.0"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"env_logger",
|
||||
"redis 0.27.6",
|
||||
"redis 0.28.2",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
@ -6578,6 +6578,29 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
"ryu",
|
||||
"sha1_smol",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redis"
|
||||
version = "0.28.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e37ec3fd44bea2ec947ba6cc7634d7999a6590aca7c35827c250bc0de502bda6"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"backon",
|
||||
"bytes",
|
||||
"combine",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"itoa",
|
||||
"num-bigint",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"ryu",
|
||||
"sha1_smol",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
@ -10056,6 +10079,17 @@ dependencies = [
|
||||
"syn 2.0.98",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06718a168365cad3d5ff0bb133aad346959a2074bd4a85c121255a11304a8626"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.93",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom"
|
||||
version = "0.1.5"
|
||||
|
@ -110,7 +110,7 @@ openssl = { version = "0.10.60", features = ["v110"] }
|
||||
parking_lot = "0.12"
|
||||
pin-project-lite = "0.2"
|
||||
rand = "0.9"
|
||||
redis = { version = "0.27" }
|
||||
redis = { version = "0.28" }
|
||||
reqwest = { version = "0.12", features = ["json", "stream"] }
|
||||
rustls = "0.23"
|
||||
rustls-pemfile = "2"
|
||||
|
@ -9,7 +9,7 @@ use diesel_async::RunQueryDsl;
|
||||
type DbError = Box<dyn std::error::Error + Send + Sync>;
|
||||
|
||||
// /// Run query using Diesel to find item by uid and return it.
|
||||
pub async fn find_item_by_uid(
|
||||
pub async fn find_item_by_id(
|
||||
conn: &mut AsyncPgConnection,
|
||||
uid: Uuid,
|
||||
) -> Result<Option<models::Item>, DbError> {
|
||||
|
@ -24,16 +24,16 @@ type DbPool = Pool<AsyncPgConnection>;
|
||||
#[get("/items/{item_id}")]
|
||||
async fn get_item(
|
||||
pool: web::Data<DbPool>,
|
||||
item_uid: web::Path<Uuid>,
|
||||
item_id: web::Path<Uuid>,
|
||||
) -> actix_web::Result<impl Responder> {
|
||||
let item_uid = item_uid.into_inner();
|
||||
let item_id = item_id.into_inner();
|
||||
|
||||
let mut conn = pool
|
||||
.get()
|
||||
.await
|
||||
.expect("Couldn't get db connection from the pool");
|
||||
|
||||
let item = actions::find_item_by_uid(&mut conn, item_uid)
|
||||
let item = actions::find_item_by_id(&mut conn, item_id)
|
||||
.await
|
||||
// map diesel query errors to a 500 error response
|
||||
.map_err(error::ErrorInternalServerError)?;
|
||||
@ -43,7 +43,7 @@ async fn get_item(
|
||||
Some(item) => HttpResponse::Ok().json(item),
|
||||
|
||||
// item was not found; return 404 response with error message
|
||||
None => HttpResponse::NotFound().body(format!("No item found with UID: {item_uid}")),
|
||||
None => HttpResponse::NotFound().body(format!("No item found with UID: {item_id}")),
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user