use axum::http::status::StatusCode;
use axum::response::IntoResponse;
use axum::response::Json;
use axum::response::Response;
use serde::Serialize;
use tera::Context;
use crate::HumusQuerySettings;
use crate::templating::HumusApiFormat;
pub trait HumusView<S, ApiFormat>: Serialize + Sized
where
S: HumusQuerySettings,
ApiFormat: HumusApiFormat,
{
fn get_template_name(&self) -> String;
fn get_status_code(&self, settings: &S) -> StatusCode;
fn initalize_template_context(&self, _context: &mut Context, _settings: &S) {}
fn update_response(&self, response: Response, _settings: &S) -> Response {
response
}
fn into_api_response(self, settings: &S, _api_format: ApiFormat) -> Response {
let response = Json(&self).into_response();
self.update_response(response, settings)
}
}