af5b4db
use axum::Json;
use axum::extract::State;
use crate::error::AuthError;
use crate::features::AuthService;
use crate::features::refresh::types::{RefreshCmd, RefreshResp};
#[utoipa::path(
post,
path = "/auth/refresh",
tag = "auth",
request_body = RefreshCmd,
responses(
(status = 200, description = "Rotated token pair.", body = RefreshResp),
(status = 401, description = "Invalid or expired refresh token.", body = super::openapi::ErrorBody),
),
)]
pub(crate) async fn handler(
State(svc): State<AuthService>,
Json(cmd): Json<RefreshCmd>,
) -> Result<Json<RefreshResp>, AuthError> {
let resp = svc.refresh(cmd).await?;
Ok(Json(resp))
}