mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-08 16:07:50 +02:00
feat: update to tauri beta, add permissions (#862)
Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
This commit is contained in:
+4
-16
@@ -12,18 +12,15 @@ use tauri::{
|
||||
AppHandle, Manager, Runtime,
|
||||
};
|
||||
|
||||
use crate::config::{Config, HttpAllowlistScope};
|
||||
pub use error::{Error, Result};
|
||||
|
||||
mod commands;
|
||||
mod config;
|
||||
mod error;
|
||||
mod scope;
|
||||
|
||||
struct Http<R: Runtime> {
|
||||
#[allow(dead_code)]
|
||||
app: AppHandle<R>,
|
||||
scope: scope::Scope,
|
||||
}
|
||||
|
||||
trait HttpExt<R: Runtime> {
|
||||
@@ -36,8 +33,8 @@ impl<R: Runtime, T: Manager<R>> HttpExt<R> for T {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
|
||||
Builder::<R, Option<Config>>::new("http")
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::<R>::new("http")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::fetch,
|
||||
@@ -45,17 +42,8 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
|
||||
commands::fetch_send,
|
||||
commands::fetch_read_body,
|
||||
])
|
||||
.setup(|app, api| {
|
||||
let default_scope = HttpAllowlistScope::default();
|
||||
app.manage(Http {
|
||||
app: app.clone(),
|
||||
scope: scope::Scope::new(
|
||||
api.config()
|
||||
.as_ref()
|
||||
.map(|c| &c.scope)
|
||||
.unwrap_or(&default_scope),
|
||||
),
|
||||
});
|
||||
.setup(|app, _api| {
|
||||
app.manage(Http { app: app.clone() });
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user