20 lines
461 B
Rust
Raw Normal View History

2021-06-27 15:11:41 +08:00
use crate::{
request::EventRequest,
response::{EventResponse, EventResponseBuilder},
};
2021-06-24 16:32:36 +08:00
pub trait Responder {
2021-06-27 15:11:41 +08:00
fn respond_to(self, req: &EventRequest) -> EventResponse;
2021-06-24 16:32:36 +08:00
}
macro_rules! impl_responder {
($res: ty) => {
impl Responder for $res {
2021-06-27 15:11:41 +08:00
fn respond_to(self, _: &EventRequest) -> EventResponse { EventResponseBuilder::Ok().data(self).build() }
2021-06-24 16:32:36 +08:00
}
};
}
impl_responder!(&'static str);
impl_responder!(String);