Skip to content
Clone
a06673b
35 lines 984 B Rust
use axum::extract::{Path, State};
use axum::http::HeaderValue;
use axum::http::header;
use axum::response::{IntoResponse, Response};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
#[utoipa::path(
get,
path = "/repo/{channel_id}/{repo_id}/editorconfig/{filename:path}",
tag = "repo",
responses((status = 200, description = "Get EditorConfig", content_type = "text/plain")),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id, filename)): Path<(Uuid, Uuid, String)>,
) -> RepoResult<Response> {
let body = svc
.get_editorconfig(claims.sub, repo_id, &filename, None)
.await?;
let resp = (
[(
header::CONTENT_TYPE,
HeaderValue::from_static("text/plain; charset=utf-8"),
)],
body,
)
.into_response();
Ok(resp)
}