pub trait Controller: Send + Sync {
// Required methods
fn index(
&self,
container: State<Arc<Container>>,
params: Query<QueryParams>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>;
fn show(
&self,
container: State<Arc<Container>>,
id: Path<String>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>;
fn create(
&self,
container: State<Arc<Container>>,
data: Json<Value>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>;
fn update(
&self,
container: State<Arc<Container>>,
id: Path<String>,
data: Json<Value>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>;
fn destroy(
&self,
container: State<Arc<Container>>,
id: Path<String>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>;
}Expand description
Send-safe controller trait for HTTP request handling Controllers delegate business logic to injected services
Required Methods§
Sourcefn index(
&self,
container: State<Arc<Container>>,
params: Query<QueryParams>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>
fn index( &self, container: State<Arc<Container>>, params: Query<QueryParams>, ) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>
List resources with pagination
Sourcefn show(
&self,
container: State<Arc<Container>>,
id: Path<String>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>
fn show( &self, container: State<Arc<Container>>, id: Path<String>, ) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>
Get single resource by ID
Sourcefn create(
&self,
container: State<Arc<Container>>,
data: Json<Value>,
) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>
fn create( &self, container: State<Arc<Container>>, data: Json<Value>, ) -> Pin<Box<dyn Future<Output = HttpResult<Response>> + Send>>
Create new resource