2021-06-24 23:37:45 +08:00
|
|
|
use crate::{
|
2021-06-25 23:53:13 +08:00
|
|
|
error::SystemError,
|
2021-06-24 23:37:45 +08:00
|
|
|
request::FlowyRequest,
|
2021-06-25 23:53:13 +08:00
|
|
|
response::{data::ResponseData, Responder},
|
2021-06-24 23:37:45 +08:00
|
|
|
};
|
2021-06-24 16:32:36 +08:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
pub enum StatusCode {
|
|
|
|
Success,
|
|
|
|
Error,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct FlowyResponse<T = ResponseData> {
|
|
|
|
pub data: T,
|
|
|
|
pub status: StatusCode,
|
2021-06-25 23:53:13 +08:00
|
|
|
pub error: Option<SystemError>,
|
2021-06-24 16:32:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl FlowyResponse {
|
|
|
|
pub fn new(status: StatusCode) -> Self {
|
|
|
|
FlowyResponse {
|
|
|
|
data: ResponseData::None,
|
|
|
|
status,
|
|
|
|
error: None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Responder for FlowyResponse {
|
|
|
|
#[inline]
|
2021-06-24 23:37:45 +08:00
|
|
|
fn respond_to(self, _: &FlowyRequest) -> FlowyResponse { self }
|
2021-06-24 16:32:36 +08:00
|
|
|
}
|