Skip to main content

reinhardt_views/
core.rs

1//! Core view traits and types.
2
3use async_trait::async_trait;
4use reinhardt_core::exception::Result;
5use reinhardt_http::{Request, Response};
6use std::collections::HashMap;
7
8/// Base trait for all generic views
9#[async_trait]
10pub trait View: Send + Sync {
11	/// Dispatch the request and return a response.
12	async fn dispatch(&self, request: Request) -> Result<Response>;
13
14	/// Returns the list of HTTP methods allowed by this view
15	fn allowed_methods(&self) -> Vec<&'static str> {
16		vec!["GET", "HEAD", "OPTIONS"]
17	}
18}
19
20/// Context data for template rendering
21pub type Context = HashMap<String, serde_json::Value>;