mirror of
https://github.com/faas-rs/faasd-in-rust.git
synced 2025-06-08 15:56:48 +00:00
fix:移除app/src中原本用于测试的函数
This commit is contained in:
parent
168b533784
commit
a671480b6f
@ -1,39 +0,0 @@
|
|||||||
use crate::types::*;
|
|
||||||
use actix_web::{HttpResponse, Responder, web};
|
|
||||||
use service::Service;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
/// 创建并启动容器
|
|
||||||
pub async fn create_container(
|
|
||||||
service: web::Data<Arc<Service>>,
|
|
||||||
info: web::Json<CreateContainerInfo>,
|
|
||||||
) -> impl Responder {
|
|
||||||
let cid = info.container_id.clone();
|
|
||||||
let image = info.image.clone();
|
|
||||||
let ns = info.ns.clone();
|
|
||||||
service.create_container(&image, &cid, &ns).await.unwrap();
|
|
||||||
HttpResponse::Ok().json("Container created successfully!")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除容器
|
|
||||||
pub async fn remove_container(
|
|
||||||
service: web::Data<Arc<Service>>,
|
|
||||||
info: web::Json<RemoveContainerInfo>,
|
|
||||||
) -> impl Responder {
|
|
||||||
let container_id = info.container_id.clone();
|
|
||||||
let ns = info.ns.clone();
|
|
||||||
service.remove_container(&container_id, &ns).await.unwrap();
|
|
||||||
HttpResponse::Ok().json("Container removed successfully!")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取容器列表
|
|
||||||
pub async fn get_container_list(
|
|
||||||
service: web::Data<Arc<Service>>,
|
|
||||||
info: web::Json<GetContainerListQuery>,
|
|
||||||
) -> impl Responder {
|
|
||||||
let ns = info.ns.clone();
|
|
||||||
let container_list = service.get_container_list(&ns).await.unwrap();
|
|
||||||
HttpResponse::Ok().json(container_list)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加更多的路由处理函数...
|
|
@ -2,11 +2,6 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix_web::{App, HttpServer, web};
|
use actix_web::{App, HttpServer, web};
|
||||||
use service::Service;
|
use service::Service;
|
||||||
|
|
||||||
pub mod handlers;
|
|
||||||
pub mod types;
|
|
||||||
|
|
||||||
use handlers::*;
|
|
||||||
use provider::{
|
use provider::{
|
||||||
handlers::{delete::delete_handler, deploy::deploy_handler, invoke_resolver::InvokeResolver},
|
handlers::{delete::delete_handler, deploy::deploy_handler, invoke_resolver::InvokeResolver},
|
||||||
proxy::proxy_handler::proxy_handler,
|
proxy::proxy_handler::proxy_handler,
|
||||||
@ -32,9 +27,6 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.app_data(web::Data::new(service.clone()))
|
.app_data(web::Data::new(service.clone()))
|
||||||
.app_data(web::Data::new(resolver.clone()))
|
.app_data(web::Data::new(resolver.clone()))
|
||||||
.app_data(web::Data::new(faas_config.clone()))
|
.app_data(web::Data::new(faas_config.clone()))
|
||||||
.route("/create-container", web::post().to(create_container))
|
|
||||||
.route("/remove-container", web::post().to(remove_container))
|
|
||||||
.route("/containers", web::get().to(get_container_list))
|
|
||||||
.route("/system/functions", web::post().to(deploy_handler))
|
.route("/system/functions", web::post().to(deploy_handler))
|
||||||
.route("/system/functions", web::delete().to(delete_handler))
|
.route("/system/functions", web::delete().to(delete_handler))
|
||||||
.route("/function/{name}{path:/?.*}", web::to(proxy_handler))
|
.route("/function/{name}{path:/?.*}", web::to(proxy_handler))
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct CreateContainerInfo {
|
|
||||||
pub container_id: String,
|
|
||||||
pub image: String,
|
|
||||||
pub ns: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct RemoveContainerInfo {
|
|
||||||
pub container_id: String,
|
|
||||||
pub ns: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
pub struct GetContainerListQuery {
|
|
||||||
pub status: Option<String>,
|
|
||||||
pub ns: String,
|
|
||||||
}
|
|
@ -1,11 +1,3 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod function_deployment;
|
pub mod function_deployment;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct CreateContainerInfo {
|
|
||||||
pub container_id: String,
|
|
||||||
pub image: String,
|
|
||||||
pub ns: String,
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user