mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-20 17:02:53 -04:00
This is a fresh start for the `artcraft` repo. The old monorepo, which included our web API gateway, job services, SRE tools, various frontends, and more has moved to `artcraft-services` You can find the full git history here: https://github.com/storytold/artcraft-services This change was motivated by the fact that the entire git history was hundreds of gigabytes in size, which is unwieldy for anyone not in the core team that doesn't care about support services outside of the core artcraft app. We wanted to keep this repo in its well-known place since we already have users and activity here. Please update your remotes to either `artcraft-services` or make a fresh clone of this repo. History can be found at the artcraft-services repo.
68 lines
2.5 KiB
Rust
68 lines
2.5 KiB
Rust
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#[path = "src/scope.rs"]
|
|
#[allow(dead_code)]
|
|
mod scope;
|
|
|
|
const COMMANDS: &[&str] = &["fetch", "fetch_cancel", "fetch_send", "fetch_read_body"];
|
|
|
|
/// HTTP scope entry.
|
|
#[derive(schemars::JsonSchema)]
|
|
#[serde(untagged)]
|
|
#[allow(unused)]
|
|
enum HttpScopeEntry {
|
|
/// A URL that can be accessed by the webview when using the HTTP APIs.
|
|
/// Wildcards can be used following the URL pattern standard.
|
|
///
|
|
/// See [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.
|
|
///
|
|
/// Examples:
|
|
///
|
|
/// - "https://*" : allows all HTTPS origin on port 443
|
|
///
|
|
/// - "https://*:*" : allows all HTTPS origin on any port
|
|
///
|
|
/// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path
|
|
///
|
|
/// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/"
|
|
Value(String),
|
|
Object {
|
|
/// A URL that can be accessed by the webview when using the HTTP APIs.
|
|
/// Wildcards can be used following the URL pattern standard.
|
|
///
|
|
/// See [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.
|
|
///
|
|
/// Examples:
|
|
///
|
|
/// - "https://*" : allows all HTTPS origin on port 443
|
|
///
|
|
/// - "https://*:*" : allows all HTTPS origin on any port
|
|
///
|
|
/// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path
|
|
///
|
|
/// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/"
|
|
url: String,
|
|
},
|
|
}
|
|
|
|
// Ensure `HttpScopeEntry` and `scope::EntryRaw` is kept in sync
|
|
fn _f() {
|
|
match scope::EntryRaw::Value(String::new()) {
|
|
scope::EntryRaw::Value(url) => HttpScopeEntry::Value(url),
|
|
scope::EntryRaw::Object { url } => HttpScopeEntry::Object { url },
|
|
};
|
|
match HttpScopeEntry::Value(String::new()) {
|
|
HttpScopeEntry::Value(url) => scope::EntryRaw::Value(url),
|
|
HttpScopeEntry::Object { url } => scope::EntryRaw::Object { url },
|
|
};
|
|
}
|
|
|
|
fn main() {
|
|
tauri_plugin::Builder::new(COMMANDS)
|
|
.global_api_script_path("./api-iife.js")
|
|
.global_scope_schema(schemars::schema_for!(HttpScopeEntry))
|
|
.build();
|
|
}
|