Initial frontend for gRPC UI

This commit is contained in:
Gregory Schier
2024-01-30 16:43:54 -08:00
parent c51d5c5377
commit c64f1108f0
16 changed files with 650 additions and 132 deletions

View File

@@ -84,7 +84,11 @@ async fn grpc_reflect(
// 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())?;
let uri = if endpoint.starts_with("http://") || endpoint.starts_with("https://") {
Uri::from_str(endpoint).map_err(|e| e.to_string())?
} else {
Uri::from_str(&format!("http://{}", endpoint)).map_err(|e| e.to_string())?
};
Ok(grpc::callable(&uri).await)
}
@@ -97,7 +101,11 @@ async fn grpc_call_unary(
// 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())?;
let uri = if endpoint.starts_with("http://") || endpoint.starts_with("https://") {
Uri::from_str(endpoint).map_err(|e| e.to_string())?
} else {
Uri::from_str(&format!("http://{}", endpoint)).map_err(|e| e.to_string())?
};
Ok(grpc::call(&uri, service, method, message).await)
}

View File

@@ -95,6 +95,19 @@ pub struct EnvironmentVariable {
pub value: String,
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct Folder {
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub id: String,
pub workspace_id: String,
pub folder_id: Option<String>,
pub model: String,
pub name: String,
pub sort_priority: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct HttpRequestHeader {
@@ -139,19 +152,6 @@ pub struct HttpRequest {
pub headers: Json<Vec<HttpRequestHeader>>,
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct Folder {
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub id: String,
pub workspace_id: String,
pub folder_id: Option<String>,
pub model: String,
pub name: String,
pub sort_priority: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct HttpResponseHeader {
@@ -190,6 +190,64 @@ impl HttpResponse {
}
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct GrpcEndpoint {
pub id: String,
pub model: String,
pub workspace_id: String,
pub request_id: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub endpoint: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct GrpcMessage {
pub created_at: NaiveDateTime,
pub content: String,
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct GrpcConnection {
pub id: String,
pub model: String,
pub workspace_id: String,
pub grpc_endpoint_id: String,
pub request_id: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub messages: Json<Vec<GrpcMessage>>,
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct GrpcRequest {
pub id: String,
pub model: String,
pub workspace_id: String,
pub grpc_endpoint_id: String,
pub grpc_connection_id: String,
pub request_id: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct GrpcResponse {
pub id: String,
pub model: String,
pub workspace_id: String,
pub grpc_endpoint_id: String,
pub grpc_connection_id: String,
pub request_id: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
}
#[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct KeyValue {