Some simplification
This commit is contained in:
parent
8fd29b5090
commit
74ac26841f
@ -77,7 +77,7 @@ fn schala_main(languages: Vec<Box<ProgrammingLanguageInterface>>, generators: Ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
if option_matches.opt_present("webapp") {
|
if option_matches.opt_present("webapp") {
|
||||||
webapp::web_main(languages, generators);
|
webapp::web_main(generators);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,13 @@ struct Output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/input", format = "application/json", data = "<input>")]
|
#[post("/input", format = "application/json", data = "<input>")]
|
||||||
fn interpreter_input(input: Json<Input>, schala_gen: State<Vec<PLIGenerator>>) -> Json<Output> {
|
fn interpreter_input(input: Json<Input>, generators: State<Vec<PLIGenerator>>) -> Json<Output> {
|
||||||
let mut schala: Box<ProgrammingLanguageInterface> = (schala_gen.get(0).unwrap())();
|
let schala_gen = generators.get(0).unwrap();
|
||||||
|
let mut schala: Box<ProgrammingLanguageInterface> = schala_gen();
|
||||||
let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default());
|
let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default());
|
||||||
Json(Output { text: code_output.to_string() })
|
Json(Output { text: code_output.to_string() })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: Vec<PLIGenerator>) {
|
pub fn web_main(language_generators: Vec<PLIGenerator>) {
|
||||||
rocket::ignite().manage(func).mount("/", routes![index, js_bundle, interpreter_input]).launch();
|
rocket::ignite().manage(language_generators).mount("/", routes![index, js_bundle, interpreter_input]).launch();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user