Some simplification

This commit is contained in:
greg 2017-10-29 12:27:24 -07:00
parent b09efd3660
commit b97da01370
2 changed files with 6 additions and 5 deletions

View File

@ -77,7 +77,7 @@ fn schala_main(languages: Vec<Box<ProgrammingLanguageInterface>>, generators: Ve
}
if option_matches.opt_present("webapp") {
webapp::web_main(languages, generators);
webapp::web_main(generators);
exit(0);
}

View File

@ -32,12 +32,13 @@ struct Output {
}
#[post("/input", format = "application/json", data = "<input>")]
fn interpreter_input(input: Json<Input>, schala_gen: State<Vec<PLIGenerator>>) -> Json<Output> {
let mut schala: Box<ProgrammingLanguageInterface> = (schala_gen.get(0).unwrap())();
fn interpreter_input(input: Json<Input>, generators: State<Vec<PLIGenerator>>) -> Json<Output> {
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());
Json(Output { text: code_output.to_string() })
}
pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: Vec<PLIGenerator>) {
rocket::ignite().manage(func).mount("/", routes![index, js_bundle, interpreter_input]).launch();
pub fn web_main(language_generators: Vec<PLIGenerator>) {
rocket::ignite().manage(language_generators).mount("/", routes![index, js_bundle, interpreter_input]).launch();
}