server created

This commit is contained in:
2025-08-31 17:20:25 +08:00
parent 89d1e468b7
commit 35fef70904
8 changed files with 33 additions and 1 deletions

View File

@@ -19,3 +19,4 @@ chrono = "0.4.41"
env_logger = "0.11.8"
futures = "0.3.31"
log = "0.4.27"
actix-web = "4.11.0"

View File

@@ -9,3 +9,4 @@ gotify-ws.workspace = true
log.workspace = true
sea-orm.workspace = true
regex.workspace = true
actix-web.workspace = true

View File

@@ -1 +1,2 @@
pub mod location;
pub mod test;

View File

@@ -0,0 +1,7 @@
use actix_web::get;
#[get("/test")]
async fn test() -> String {
// HttpResponse::Ok().body("test")
String::from("test")
}

View File

@@ -1,3 +1,4 @@
mod handler;
mod test;
#[tokio::main]

View File

@@ -58,7 +58,7 @@ fn get_id_file() {
for line in buffer.lines() {
// println!("line {}", line.unwrap());
if let Some((name, id)) = split_str(line.unwrap().as_str()) {
if let Some((_, id)) = split_str(line.unwrap().as_str()) {
// println!("name: {}, id: {}", name, id);
if id.len() != 18 {

View File

@@ -0,0 +1,20 @@
use crate::handler::test;
use actix_web::{App, HttpServer};
#[tokio::test]
async fn run_application() {
println!("run application");
let serve = HttpServer::new(move || {
let app = App::new();
let app = app.service(test::test);
app
});
serve
.bind("127.0.0.1:8080")
.expect("端口绑定失败")
.run()
.await
.expect("服务启动失败");
}

View File

@@ -1,3 +1,4 @@
#[cfg(test)]
mod base_api;
mod id_card;
mod main;