Skip to content
Clone

feat(issues): add issue_stopwatch start handler

zhenyi committed
parent 7bf5196 commit ad97d98 Browse files

1 file changed

+27 −0

Added lib/issues/handler/issue_stopwatch/start.rs View lib/issues/handler/issue_stopwatch/start.rs
@@ -0,0 +1,27 @@
1use axum::Json;
2use axum::extract::{Path, State};
3use axum::http::StatusCode;
4use jwt::extractor::AuthUser;
5use uuid::Uuid;
6
7use crate::error::IssueResult;
8use crate::features::IssueService;
9use crate::features::issue_stopwatch::StopwatchView;
10
11#[utoipa::path(
12 post,
13 path = "/issues/{channel_id}/{issue_id}/stopwatch",
14 tag = "issues",
15 responses((status = 201, description = "Start stopwatch", body = StopwatchView)),
16 security(("bearer_auth" = []))
17)]
18pub(crate) async fn handler(
19 State(svc): State<IssueService>,
20 AuthUser { claims }: AuthUser,
21 Path((channel_id, issue_id)): Path<(Uuid, Uuid)>,
22) -> IssueResult<(StatusCode, Json<StopwatchView>)> {
23 let view = svc
24 .start_watch(claims.sub, channel_id, issue_id)
25 .await?;
26 Ok((StatusCode::CREATED, Json(view)))
27}
No newline at end of file