mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 13:52:46 -07:00
25 lines
488 B
Rust
25 lines
488 B
Rust
|
|
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()
|
||
|
|
}
|
||
|
|
}
|