feat: create base payload, request and response data structures

This commit is contained in:
Valerio Ageno
2024-05-19 12:22:56 +02:00
parent d4c9b25b90
commit 208c18c94a
8 changed files with 102 additions and 24 deletions
+24
View File
@@ -0,0 +1,24 @@
use serde::Serialize;
use crate::request::Location;
use crate::Request;
#[derive(Serialize)]
/// This is the data shared to the client
pub struct Payload<'a> {
router: Location<'a>,
props: String,
}
impl<'a> Payload<'a> {
pub fn new(req: &Request<'a>, props: String) -> Payload<'a> {
Payload {
router: req.location(),
props,
}
}
pub fn client_payload(&self) -> String {
serde_json::to_string(&self).unwrap()
}
}