diff --git a/fl-server/src/handlers.rs b/fl-server/src/handlers.rs index 3ff53cc..e301e3b 100644 --- a/fl-server/src/handlers.rs +++ b/fl-server/src/handlers.rs @@ -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") ) @@ -55,11 +55,6 @@ pub struct FlistBody { pub registry_token: Option, } -#[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, @@ -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, - Json(body): Json, + Path(flist_path): Path, ) -> impl IntoResponse { - let fl_path = body.flist_path; + let fl_path = flist_path; // Validations if fl_path.starts_with("/") { diff --git a/fl-server/src/main.rs b/fl-server/src/main.rs index 30361c4..315e0d3 100644 --- a/fl-server/src/main.rs +++ b/fl-server/src/main.rs @@ -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));