diff --git a/src/main.rs b/src/main.rs
index 11141f7..a686221 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -106,7 +106,7 @@ async fn get_ksiazka(
autor,
cena,
COALESCE('/images/' || obraz_url, '/images/placeholder.jpg') as obraz_url,
- opis
+ COALESCE(opis, 'Brak opisu') as opis
FROM ksiazki
WHERE id = $1
"#,
@@ -116,8 +116,11 @@ async fn get_ksiazka(
.await
{
Ok(Some(book)) => HttpResponse::Ok().json(book),
- Ok(None) => HttpResponse::NotFound().finish(),
- Err(e) => HttpResponse::InternalServerError().body(format!("Błąd: {}", e)),
+ Ok(None) => HttpResponse::NotFound().json(json!({"error": "Książka nie znaleziona"})),
+ Err(e) => {
+ log::error!("Błąd bazy danych: {}", e);
+ HttpResponse::InternalServerError().json(json!({"error": "Błąd serwera"}))
+ }
}
}
@@ -162,6 +165,7 @@ async fn main() -> std::io::Result<()> {
.wrap(cors)
.wrap(actix_web::middleware::Logger::default())
.service(get_ksiazki)
+ .service(get_ksiazka)
.service(auth::rejestracja)
.service(auth::login)
.service(
diff --git a/static/book.html b/static/book.html
index dd02a63..8c567a9 100644
--- a/static/book.html
+++ b/static/book.html
@@ -78,6 +78,8 @@
+
+