Skip to content
Clone
c7c96f9
24 lines 803 B Rust
use axum::extract::State;
use crate::error::AuthError;
use crate::features::AuthService;
use export::auth::refresh::{RefreshCmd, RefreshResp};
use export::data::{AppRequest, AppRequestData, AppResponseData};
#[utoipa::path(
post,
path = "/auth/refresh",
tag = "auth",
request_body = AppRequestData<RefreshCmd>,
responses(
(status = 200, description = "Rotated token pair.", body = AppResponseData<RefreshResp>),
(status = 401, description = "Invalid or expired refresh token.", body = super::openapi::ErrorBody),
),
)]
pub(crate) async fn handler(
State(svc): State<AuthService>,
cmd: AppRequest<RefreshCmd>,
) -> Result<AppResponseData<RefreshResp>, AuthError> {
let resp = svc.refresh(cmd.into_inner()).await?;
Ok(AppResponseData::ok(resp))
}