refactor: move deleted tauri APIs, prepare for next release (#355)

This commit is contained in:
Lucas Fernandes Nogueira
2023-05-13 08:32:30 -07:00
committed by GitHub
parent 937e6a5be6
commit 702b7b36bd
45 changed files with 1412 additions and 31963 deletions
+12 -4
View File
@@ -1,3 +1,4 @@
use config::{Config, HttpAllowlistScope};
pub use reqwest as client;
use tauri::{
plugin::{Builder, TauriPlugin},
@@ -7,6 +8,7 @@ use tauri::{
use std::{collections::HashMap, sync::Mutex};
mod commands;
mod config;
mod error;
mod scope;
@@ -33,18 +35,24 @@ impl<R: Runtime, T: Manager<R>> HttpExt<R> for T {
}
}
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("http")
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
Builder::<R, Option<Config>>::new("http")
.invoke_handler(tauri::generate_handler![
commands::create_client,
commands::drop_client,
commands::request
])
.setup(|app, _api| {
.setup(|app, api| {
let default_scope = HttpAllowlistScope::default();
app.manage(Http {
app: app.clone(),
clients: Default::default(),
scope: scope::Scope::new(&app.config().tauri.allowlist.http.scope),
scope: scope::Scope::new(
api.config()
.as_ref()
.map(|c| &c.scope)
.unwrap_or(&default_scope),
),
});
Ok(())
})