33 lines
1.1 KiB
Rust
33 lines
1.1 KiB
Rust
use crate::{ApiResponse, error::ApiError};
|
|
use actix_web::{HttpResponse, Result, web};
|
|
use service::AppService;
|
|
use service::workspace::info::{WorkspaceProjectsQuery, WorkspaceProjectsResponse};
|
|
use session::Session;
|
|
|
|
#[utoipa::path(
|
|
get,
|
|
path = "/api/workspaces/{slug}/projects",
|
|
params(
|
|
("slug" = String, Path, description = "Workspace slug"),
|
|
),
|
|
responses(
|
|
(status = 200, description = "List workspace projects", body = ApiResponse<WorkspaceProjectsResponse>),
|
|
(status = 401, description = "Unauthorized"),
|
|
(status = 403, description = "Not a workspace member"),
|
|
(status = 404, description = "Workspace not found"),
|
|
),
|
|
tag = "Workspace"
|
|
)]
|
|
pub async fn workspace_projects(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
path: web::Path<String>,
|
|
query: web::Query<WorkspaceProjectsQuery>,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let slug = path.into_inner();
|
|
let resp = service
|
|
.workspace_projects(&session, slug, query.into_inner())
|
|
.await?;
|
|
Ok(ApiResponse::ok(resp).to_response())
|
|
}
|