Finally removed schala dependency
Now need to clena up everything
This commit is contained in:
parent
6e8f57e54f
commit
277e039251
@ -3,7 +3,6 @@ use rocket::State;
|
|||||||
use rocket::response::Content;
|
use rocket::response::Content;
|
||||||
use rocket::http::ContentType;
|
use rocket::http::ContentType;
|
||||||
use rocket_contrib::Json;
|
use rocket_contrib::Json;
|
||||||
use schala_lang;
|
|
||||||
use language::{ProgrammingLanguageInterface, EvalOptions};
|
use language::{ProgrammingLanguageInterface, EvalOptions};
|
||||||
use WEBFILES;
|
use WEBFILES;
|
||||||
use ::PLIGenerator;
|
use ::PLIGenerator;
|
||||||
@ -34,14 +33,12 @@ struct Output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/input", format = "application/json", data = "<input>")]
|
#[post("/input", format = "application/json", data = "<input>")]
|
||||||
fn interpreter_input(input: Json<Input>) -> Json<Output> {
|
fn interpreter_input(input: Json<Input>, schala_gen: State<Mutex<PLIGenerator>>) -> Json<Output> {
|
||||||
let mut schala = schala_lang::Schala::new();
|
let mut schala: Box<ProgrammingLanguageInterface> = schala_gen.lock().unwrap()();
|
||||||
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: PLIGenerator) {
|
pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: PLIGenerator) {
|
||||||
let wrapped_func = Mutex::new(func);
|
rocket::ignite().manage(Mutex::new(func)).mount("/", routes![index, js_bundle, interpreter_input]).launch();
|
||||||
//let wrapped_func = Box::new(|| { 5 });
|
|
||||||
rocket::ignite().manage(wrapped_func).mount("/", routes![index, js_bundle, interpreter_input]).launch();
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user