diff --git a/src/webapp.rs b/src/webapp.rs index a0f706d..5d0023d 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -3,7 +3,6 @@ use rocket::State; use rocket::response::Content; use rocket::http::ContentType; use rocket_contrib::Json; -use schala_lang; use language::{ProgrammingLanguageInterface, EvalOptions}; use WEBFILES; use ::PLIGenerator; @@ -34,14 +33,12 @@ struct Output { } #[post("/input", format = "application/json", data = "")] -fn interpreter_input(input: Json) -> Json { - let mut schala = schala_lang::Schala::new(); +fn interpreter_input(input: Json, schala_gen: State>) -> Json { + let mut schala: Box = schala_gen.lock().unwrap()(); 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>, func: PLIGenerator) { - let wrapped_func = Mutex::new(func); - //let wrapped_func = Box::new(|| { 5 }); - rocket::ignite().manage(wrapped_func).mount("/", routes![index, js_bundle, interpreter_input]).launch(); + rocket::ignite().manage(Mutex::new(func)).mount("/", routes![index, js_bundle, interpreter_input]).launch(); }