mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 07:06:12 +00:00
Pass common plugin chain into web handler
This commit is contained in:
@@ -207,7 +207,7 @@ fn main() {
|
|||||||
|
|
||||||
println!("Server listening on port {}", port);
|
println!("Server listening on port {}", port);
|
||||||
|
|
||||||
web::start(config.clone(), project.clone(), vfs.clone());
|
web::start(config.clone(), project.clone(), &PLUGIN_CHAIN, vfs.clone());
|
||||||
},
|
},
|
||||||
("pack", _) => {
|
("pack", _) => {
|
||||||
eprintln!("'rojo pack' is not yet implemented!");
|
eprintln!("'rojo pack' is not yet implemented!");
|
||||||
|
|||||||
15
src/web.rs
15
src/web.rs
@@ -10,7 +10,6 @@ use project::Project;
|
|||||||
use vfs::{Vfs, VfsChange};
|
use vfs::{Vfs, VfsChange};
|
||||||
use rbx::RbxItem;
|
use rbx::RbxItem;
|
||||||
use plugin::PluginChain;
|
use plugin::PluginChain;
|
||||||
use plugins::{ScriptPlugin, DefaultPlugin};
|
|
||||||
|
|
||||||
static MAX_BODY_SIZE: usize = 25 * 1024 * 1025; // 25 MiB
|
static MAX_BODY_SIZE: usize = 25 * 1024 * 1025; // 25 MiB
|
||||||
|
|
||||||
@@ -102,19 +101,11 @@ where
|
|||||||
Some(parsed)
|
Some(parsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(config: Config, project: Project, vfs: Arc<Mutex<Vfs>>) {
|
pub fn start(config: Config, project: Project, plugin_chain: &'static PluginChain, vfs: Arc<Mutex<Vfs>>) {
|
||||||
let address = format!("localhost:{}", config.port);
|
let address = format!("localhost:{}", config.port);
|
||||||
|
|
||||||
let server_id = config.server_id.to_string();
|
let server_id = config.server_id.to_string();
|
||||||
|
|
||||||
// Fine, rouille, I'll put things in a 'static Arc<Mutex>...
|
|
||||||
lazy_static! {
|
|
||||||
static ref PLUGIN_CHAIN: Arc<Mutex<PluginChain>> = Arc::new(Mutex::new(PluginChain::new(vec![
|
|
||||||
Box::new(ScriptPlugin::new()),
|
|
||||||
Box::new(DefaultPlugin::new()),
|
|
||||||
])));
|
|
||||||
}
|
|
||||||
|
|
||||||
rouille::start_server(address, move |request| {
|
rouille::start_server(address, move |request| {
|
||||||
router!(request,
|
router!(request,
|
||||||
(GET) (/) => {
|
(GET) (/) => {
|
||||||
@@ -146,8 +137,6 @@ pub fn start(config: Config, project: Project, vfs: Arc<Mutex<Vfs>>) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
(POST) (/read) => {
|
(POST) (/read) => {
|
||||||
let plugin_chain = PLUGIN_CHAIN.lock().unwrap();
|
|
||||||
|
|
||||||
let read_request: Vec<Vec<String>> = match read_json(&request) {
|
let read_request: Vec<Vec<String>> = match read_json(&request) {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => return rouille::Response::empty_400(),
|
None => return rouille::Response::empty_400(),
|
||||||
@@ -188,8 +177,6 @@ pub fn start(config: Config, project: Project, vfs: Arc<Mutex<Vfs>>) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
(POST) (/write) => {
|
(POST) (/write) => {
|
||||||
let _plugin_chain = PLUGIN_CHAIN.lock().unwrap();
|
|
||||||
|
|
||||||
let _write_request: Vec<WriteSpecifier> = match read_json(&request) {
|
let _write_request: Vec<WriteSpecifier> = match read_json(&request) {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => return rouille::Response::empty_400(),
|
None => return rouille::Response::empty_400(),
|
||||||
|
|||||||
Reference in New Issue
Block a user