use crate::tina::data::app_error::AppError;
use crate::tina::data::AppResult;
use http::header::HeaderName;
use http::HeaderValue;
use std::borrow::Cow;
pub type ResRaw = super::response_ext::ResRaw;
pub type Response = super::response_ext::Response;
pub trait ResponseAttribute {
fn success(&self) -> bool;
fn set_success(&mut self, flag: bool);
fn get_error_message(&self) -> Option<Cow<str>>;
}
impl ResponseAttribute for AppError {
fn success(&self) -> bool {
false
}
fn set_success(&mut self, _: bool) {
}
fn get_error_message(&self) -> Option<Cow<str>> {
Some(Cow::Owned(format!("{}", self)))
}
}
pub trait HttpResponseExt: ResponseAttribute {
fn add_response_header(&mut self, header_name: HeaderName, header_value: HeaderValue) -> AppResult<()>;
}