Hooked up test call from frontend!

This commit is contained in:
Gregory Schier
2024-01-29 20:50:43 -08:00
parent 219a6b78da
commit dbdce4cf9a
9 changed files with 821 additions and 9 deletions

View File

@@ -8,12 +8,15 @@ extern crate core;
#[macro_use]
extern crate objc;
use ::http::Uri;
use std::collections::HashMap;
use std::env::current_dir;
use std::fs::{create_dir_all, read_to_string, File};
use std::process::exit;
use std::str::FromStr;
use fern::colors::ColoredLevelConfig;
use grpc::ServiceDefinition;
use log::{debug, error, info, warn};
use rand::random;
use serde::Serialize;
@@ -75,6 +78,29 @@ async fn migrate_db(
Ok(())
}
#[tauri::command]
async fn grpc_reflect(
endpoint: &str,
// app_handle: AppHandle<Wry>,
// db_instance: State<'_, Mutex<Pool<Sqlite>>>,
) -> Result<Vec<ServiceDefinition>, String> {
let uri = Uri::from_str(endpoint).map_err(|e| e.to_string())?;
Ok(grpc::callable(&uri).await)
}
#[tauri::command]
async fn grpc_call_unary(
endpoint: &str,
service: &str,
method: &str,
message: &str,
// app_handle: AppHandle<Wry>,
// db_instance: State<'_, Mutex<Pool<Sqlite>>>,
) -> Result<String, String> {
let uri = Uri::from_str(endpoint).map_err(|e| e.to_string())?;
Ok(grpc::call(&uri, service, method, message).await)
}
#[tauri::command]
async fn send_ephemeral_request(
mut request: models::HttpRequest,
@@ -977,6 +1003,8 @@ fn main() {
get_request,
get_settings,
get_workspace,
grpc_call_unary,
grpc_reflect,
import_data,
list_cookie_jars,
list_environments,