diff --git a/src/api/router.rs b/src/api/router.rs index ef0263bb..52bfc932 100644 --- a/src/api/router.rs +++ b/src/api/router.rs @@ -8,7 +8,7 @@ pub struct ApiMethod { pub description: &'static str, pub parameters: Schema, pub returns: Schema, - pub handler: Box Result + Send + Sync>, + pub handler: fn(Value, &ApiMethod) -> Result, } pub enum SubRoute { diff --git a/src/api/server.rs b/src/api/server.rs index 3c61b4ac..d1f87135 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -181,7 +181,7 @@ fn handle_sync_api_request( tokio::spawn(task); */ - let res = (*info.handler)(params, info)?; + let res = (info.handler)(params, info)?; Ok(res) diff --git a/src/api3.rs b/src/api3.rs index 605cf27c..9c5fec07 100644 --- a/src/api3.rs +++ b/src/api3.rs @@ -32,16 +32,16 @@ pub fn router() -> Router { description: "Another Endpoint.", parameters: parameter!{}, returns: Schema::Null, - handler: Box::new(|param, _info| { + handler: |param, _info| { println!("This is a clousure handler: {}", param); Ok(json!(null)) - }) + }, }); let route2 = Router::new() .get(ApiMethod { - handler: Box::new(test_sync_api_handler), + handler: test_sync_api_handler, description: "This is a simple test.", parameters: parameter!{ force => Boolean!{