Skip to content
Clone
use axum::extract::{Path, State};
use export::data::AppResponseData;

use jwt::extractor::AuthUser;
use uuid::Uuid;

use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::extras::LicensesResponse;

#[utoipa::path(
    get,
    path = "/repo/{channel_id}/{repo_id}/licenses",
    tag = "repo",
    responses((status = 200, description = "List detected licenses", body = AppResponseData<LicensesResponse>)),
    security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
    State(svc): State<RepoService>,
    AuthUser { claims }: AuthUser,
    Path((_, repo_id)): Path<(Uuid, Uuid)>,
) -> RepoResult<AppResponseData<LicensesResponse>> {
    let out = svc.get_licenses(claims.sub, repo_id).await?;
    Ok(AppResponseData::ok(out))
}