Skip to content

Commit

Permalink
feat: try to add for query params
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 12, 2023
1 parent 5efb8c8 commit 9980b2e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 26 deletions.
5 changes: 2 additions & 3 deletions counit-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::net::SocketAddr;

use axum::{Extension, Router, routing::{get, post}};
use serde::{Deserialize, Serialize};
use tracing::info;

use crate::server::{archguard, datamap_api, embedding_api, translate_api};
use crate::server::{archguard_api, datamap_api, embedding_api, translate_api};
pub mod server;

#[tokio::main]
Expand All @@ -20,7 +19,7 @@ async fn main() -> anyhow::Result<()> {
// knowledge init
.nest("/translate/domain_language", translate_api::router())
//align to archguard api
.nest("/scanner", archguard::router())
.nest("/scanner", archguard_api::router())
;

api = api.route("/health", get(health));
Expand Down
22 changes: 0 additions & 22 deletions counit-server/src/server/archguard.rs

This file was deleted.

69 changes: 69 additions & 0 deletions counit-server/src/server/archguard_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
use axum::{Json, Router};

Check warning on line 1 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused import: `Json`
use axum::extract::{Path, Query};

Check warning on line 2 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused imports: `Path`, `Query`
use axum::http::StatusCode;

Check warning on line 3 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused import: `axum::http::StatusCode`
use serde::Deserialize;

use crate::server::chapi_model::CodeDataStruct;

Check warning on line 6 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused import: `crate::server::chapi_model::CodeDataStruct`

pub fn router() -> Router {
use axum::routing::*;

Router::new()
// .route("/:systemId/reporting/class-items", post(save_class_items))
// .route("/:systemId/reporting/container-services", post(save_container))
}

#[derive(Deserialize)]
pub struct ArchGuardParams {
language: String,
path: String,
}

//
// pub async fn save_class_items(
// Path(systemId): Path<u32>,
// params: Query<ArchGuardParams>,
// inputs: Vec<CodeDataStruct>,
// ) -> (StatusCode, Json<()>) {
// println!("systemId: {}", systemId);
// println!("inputs: {}", serde_json::to_value(&inputs).unwrap());
// println!("save_class_items");
//
// (StatusCode::CREATED, Json(()))
// }
//
// pub async fn save_container(
// Path(systemId): Path<u32>,
// params: Query<ArchGuardParams>,
// inputs: Vec<ContainerServiceDto>,
// ) -> (StatusCode, Json<()>) {
// println!("save_container");
//
// (StatusCode::CREATED, Json(()))
// }

#[derive(Deserialize)]
pub struct ContainerServiceDto {
name: String,
demands: Vec<ContainerDemand>,
resources: Vec<ContainerSupply>,
}

#[derive(Deserialize)]
pub struct ContainerSupply {
source_url: String,
source_http_method: String,
package_name: String,
class_name: String,
method_name: String,
}

#[derive(Deserialize)]
pub struct ContainerDemand {
source_caller: String,
call_routes: Vec<String>,
base: String,
target_url: String,
target_http_method: String,
call_data: String,
}
3 changes: 2 additions & 1 deletion counit-server/src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod embedding_api;
pub mod translate_api;
pub mod datamap_api;
pub mod archguard;
pub mod archguard_api;
pub mod chapi_model;

0 comments on commit 9980b2e

Please sign in to comment.