Skip to content

Commit

Permalink
Merge branch 'development_preview_flist' into development_fl_server_f…
Browse files Browse the repository at this point in the history
…rontend
  • Loading branch information
Nabil-Salah committed Aug 22, 2024
2 parents 7f29318 + 02f6380 commit c76c6d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
19 changes: 8 additions & 11 deletions fl-server/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use uuid::Uuid;
#[derive(OpenApi)]
#[openapi(
paths(health_check_handler, create_flist_handler, get_flist_state_handler, preview_flist_handler, list_flists_handler, sign_in_handler),
components(schemas(DirListTemplate, DirLister, FlistBody, Job, ResponseError, ErrorTemplate, TemplateErr, ResponseResult, FileInfo, SignInBody, FlistState, SignInResponse, FlistStateInfo, PreviewResponse, PreviewBody)),
components(schemas(DirListTemplate, DirLister, FlistBody, Job, ResponseError, ErrorTemplate, TemplateErr, ResponseResult, FileInfo, SignInBody, FlistState, SignInResponse, FlistStateInfo, PreviewResponse)),
tags(
(name = "fl-server", description = "Flist conversion API")
)
Expand All @@ -55,11 +55,6 @@ pub struct FlistBody {
pub registry_token: Option<String>,
}

#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
pub struct PreviewBody {
pub flist_path: String,
}

#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
pub struct PreviewResponse {
pub content: Vec<String>,
Expand Down Expand Up @@ -377,22 +372,24 @@ pub async fn list_flists_handler(

#[utoipa::path(
get,
path = "/v1/api/fl/preview",
request_body = PreviewBody,
path = "/v1/api/fl/preview/{flist_path}",
responses(
(status = 200, description = "Flist preview result", body = PreviewResponse),
(status = 400, description = "Bad request"),
(status = 401, description = "Unauthorized user"),
(status = 403, description = "Forbidden"),
(status = 500, description = "Internal server error"),
)
),
params(
("flist_path" = String, Path, description = "flist file path")
)
)]
#[debug_handler]
pub async fn preview_flist_handler(
Extension(cfg): Extension<config::Config>,
Json(body): Json<PreviewBody>,
Path(flist_path): Path<String>,
) -> impl IntoResponse {
let fl_path = body.flist_path;
let fl_path = flist_path;

// Validations
if fl_path.starts_with("/") {
Expand Down
5 changes: 4 additions & 1 deletion fl-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ async fn app() -> Result<()> {
auth::authorize,
)),
)
.route("/v1/api/fl/preview", get(handlers::preview_flist_handler))
.route(
"/v1/api/fl/preview/:flist_path",
get(handlers::preview_flist_handler),
)
.route("/v1/api/fl", get(handlers::list_flists_handler))
.route("/*path", get(serve_flists::serve_flists));

Expand Down

0 comments on commit c76c6d3

Please sign in to comment.