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