Krys4lide/tauri/src/main.rs

28 lines
955 B
Rust
Raw Normal View History

2024-07-16 11:02:53 +02:00
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::http::ResponseBuilder;
2024-07-16 11:02:53 +02:00
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.register_uri_scheme_protocol("clego", |_app, request| {
let path = request.uri();
let body = format!("<html><body>Hello from Rust! Path: {}</body></html>", path);
println!("body: {}", body);
let body_bytes: Vec<u8> = body.into_bytes();
ResponseBuilder::new()
.body(body_bytes)
})
2024-07-16 11:02:53 +02:00
.run(tauri::generate_context!())
.expect("error while running tauri application");
}