Skip to content

Commit

Permalink
Move package_slug to route
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Sep 3, 2023
1 parent e791ac7 commit 738e703
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions judge-server/src/service/judge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub fn route(cfg: &mut web::ServiceConfig) {
#[derive(Debug, ToSchema, Deserialize)]
pub struct RunJudgeBody {
src: String,
src_language: Language,
package_slug: PathBuf,
src_language: Language
}

#[utoipa::path(
Expand All @@ -40,11 +39,13 @@ pub struct RunJudgeBody {
(status = 200, description = "Judge run successfully")
)
)]
#[post("")]
#[post("/{package_slug}")]
pub async fn run_judge(
path: web::Path<String>,
body: web::Json<RunJudgeBody>,
problem_package_dir: web::Data<PathBuf>,
) -> Result<HttpResponse, ServiceError> {
let package_slug = path.into_inner();
log::debug!("receive body: {:?}", body);

let uuid = uuid::Uuid::new_v4();
Expand All @@ -66,7 +67,7 @@ pub async fn run_judge(
tokio::spawn(async move {
let new_builder_result = JudgeBuilder::new(JudgeBuilderInput {
package_type: PackageType::ICPC,
package_path: problem_package_dir.join(body.package_slug.clone()),
package_path: problem_package_dir.join(package_slug.clone()),
runtime_path: runtime_path.clone(),
src_language: body.src_language,
src_path: runtime_path.clone().join(&src_file_name),
Expand Down

0 comments on commit 738e703

Please sign in to comment.