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 async fn dispatch(&self, request: Request) -> Result<Response>;
12
13 /// Returns the list of HTTP methods allowed by this view
14 fn allowed_methods(&self) -> Vec<&'static str> {
15 vec!["GET", "HEAD", "OPTIONS"]
16 }
17}
18
19/// Context data for template rendering
20pub type Context = HashMap<String, serde_json::Value>;