mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 13:52:46 -07:00
feat: create base payload, request and response data structures
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user