mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-04 15:47:50 +02:00
refactor: move deleted tauri APIs, prepare for next release (#355)
This commit is contained in:
committed by
GitHub
parent
937e6a5be6
commit
702b7b36bd
+12
-4
@@ -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(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user