Skip to content
Snippets Groups Projects
Commit 06d930a3 authored by Stephen D's avatar Stephen D
Browse files

Merge branch 'uuid_in_response' into 'master'

Return UUID when enquing

See merge request !6
parents 4686cfa7 4c4b8cc6
No related branches found
No related tags found
1 merge request!6Return UUID when enquing
......@@ -17,6 +17,7 @@ pub struct EnqueueImageBody {
#[derive(Serialize)]
pub struct EnqueueImageResponse {
scraped: bool,
uuid: String,
formats: HashMap<String, String>,
}
......@@ -56,9 +57,10 @@ pub async fn enqueue_image(
}
}
let uuid = Uuid::new_v4();
match sqlx::query!(
"INSERT INTO images(id, original_url, callback_url) VALUES ($1, $2, $3)",
Uuid::new_v4(),
uuid,
body.image_url,
body.callback_url
)
......@@ -67,6 +69,7 @@ pub async fn enqueue_image(
{
Ok(_) => Ok(warp::reply::json(&EnqueueImageResponse {
scraped: false,
uuid: uuid.to_string(),
formats: HashMap::new(),
})
.into_response()),
......@@ -112,6 +115,7 @@ async fn handle_unique_key_violation(
Ok(warp::reply::json(&EnqueueImageResponse {
scraped: row.is_scraped,
uuid: row.id.to_string(),
formats: match &row.extension {
Some(ext) => formats
.into_iter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment