prepping for webserver stuff
This commit is contained in:
28
src/main.rs
28
src/main.rs
@@ -7,6 +7,8 @@ use std::{env, process};
|
||||
|
||||
mod runner;
|
||||
|
||||
mod webserver;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let mut args = env::args();
|
||||
@@ -28,16 +30,18 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Long lived lua instance
|
||||
let mut lua_instance = lua::create_instance();
|
||||
|
||||
let engine_table: mlua::Table =
|
||||
lua::intialise_lua(&mut lua_instance, config_location).expect("Failed to initialise lua");
|
||||
|
||||
let engine_vec = engine_decoder::get_engine_vec(&mut lua_instance, engine_table)
|
||||
.expect("could not get engines");
|
||||
|
||||
let results = runner::run_engines(engine_vec, "test".to_string()).await;
|
||||
|
||||
println!("{:#?}", results)
|
||||
// // Long lived lua instance
|
||||
// let mut lua_instance = lua::create_instance();
|
||||
//
|
||||
// let engine_table: mlua::Table =
|
||||
// lua::intialise_lua(&mut lua_instance, config_location).expect("Failed to initialise lua");
|
||||
//
|
||||
// let engine_vec = engine_decoder::get_engine_vec(&mut lua_instance, engine_table)
|
||||
// .expect("could not get engines");
|
||||
//
|
||||
// let results = runner::run_engines(engine_vec, "test".to_string()).await;
|
||||
//
|
||||
// println!("{:#?}", results)
|
||||
//
|
||||
webserver::main_server().await;
|
||||
}
|
||||
|
||||
20
src/webserver/mod.rs
Normal file
20
src/webserver/mod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use axum::{Router, extract::Query, routing::get};
|
||||
use serde;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Params {
|
||||
value: String,
|
||||
}
|
||||
|
||||
pub async fn main_server() {
|
||||
// build our application with a single route
|
||||
let app = Router::new().route("/", get(handler));
|
||||
|
||||
// run our app with hyper, listening globally on port 3000
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn handler(Query(params): Query<Params>) -> String {
|
||||
format!("Value is: {}", params.value)
|
||||
}
|
||||
Reference in New Issue
Block a user