Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 797ebad5 authored by Ida Made Revindra Dikta Mahendra's avatar Ida Made Revindra Dikta Mahendra
Browse files

[CHORE]: Implement update method in Subscriber model to send notification HTTP requests

parent 75b17204
No related branches found
No related tags found
No related merge requests found
use rocket::serde::{Deserialize, Serialize};
use rocket::log;
use rocket::serde::json::to_string;
......@@ -11,4 +10,17 @@ use crate::model::notification::Notification;
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);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment