use std::collections::HashMap;
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct RESTRequest {
pub method: String,
pub path: String,
pub path_elements: Vec<String>,
pub body: String,
pub query_parameters: HashMap<String, String>,
}
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct RESTResponse {
pub code: u16,
pub body: String,
pub content_type: String,
}
impl RESTResponse {
pub fn new(code: u16, body: &str, content_type: &str) -> Self {
Self {
code,
body: body.to_string(),
content_type: content_type.to_string(),
}
}
pub fn with_text(code: u16, body: &str) -> Self {
Self::new(code, body, "text/plain")
}
pub fn with_json(code: u16, body: &str) -> Self {
Self::new(code, body, "application/json")
}
}
pub trait GetRESTResponse {
fn get_rest_response(&self) -> Option<RESTResponse>;
}