Skip to content
Clone

feat(project): add links add handler

zhenyi committed
parent 376e058 commit e81735d Browse files

1 file changed

+28 −0

Added lib/project/handler/links/add.rs View lib/project/handler/links/add.rs
@@ -0,0 +1,28 @@
1use axum::extract::{Path, State};
2use export::data::{AppRequest, AppRequestData, AppResponseData};
3use jwt::extractor::AuthUser;
4
5use crate::error::ProjectResult;
6use crate::features::ProjectService;
7use crate::features::links::{AddLinkCmd, LinkView};
8use crate::handler::query::ProjectPath;
9
10#[utoipa::path(
11 post,
12 path = "/spaces/{space_id}/projects/{project_id}/links",
13 tag = "project",
14 request_body = AppRequestData<AddLinkCmd>,
15 responses((status = 201, description = "Add a link", body = AppResponseData<LinkView>)),
16 security(("bearer_auth" = []))
17)]
18pub(crate) async fn handler(
19 State(svc): State<ProjectService>,
20 AuthUser { claims }: AuthUser,
21 Path(path): Path<ProjectPath>,
22 input: AppRequest<AddLinkCmd>,
23) -> ProjectResult<AppResponseData<LinkView>> {
24 let view = svc
25 .add_link(claims.sub, path.space_id, path.project_id, input.into_inner())
26 .await?;
27 Ok(AppResponseData::ok(view).with_code(201))
28}
No newline at end of file