Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 153502f6 authored by noQils's avatar noQils
Browse files

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

parent 082490c4
No related branches found
No related tags found
No related merge requests found
......@@ -11,3 +11,17 @@ pub struct Subscriber {
pub url: String,
pub name: String,
}
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.
Finish editing this message first!
Please register or to comment