Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit a6047dc2 authored by Scallss's avatar Scallss
Browse files

Implement update method in Subscriber model to send notification HTTP requests.

parent 507c744d
Branches
No related tags found
No related merge requests found
......@@ -10,4 +10,20 @@ use crate::model::notification::Notification;
pub struct Subscriber {
pub url: String,
pub name:String,
}
\ No newline at end of file
}
impl Subscriber {
#[tokio::main]
pub async fn update(&self, payload: Notification) {
REQWEST_CLIENT
.post(&self.url)
.header("Content-Type", "JSON")
.body(to_string(&payload).unwrap())
.send().await.ok();
log::warn_!(
"Sent {} notification of: [{}] {} to: {}",
payload.status, payload.product_type, payload.product_title, self.url
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment