tianyun há 3 anos atrás
pai
commit
b2246bcc29
3 ficheiros alterados com 107 adições e 682 exclusões
  1. 84 674
      Cargo.lock
  2. 5 4
      Cargo.toml
  3. 18 4
      src/main.rs

Diff do ficheiro suprimidas por serem muito extensas
+ 84 - 674
Cargo.lock


+ 5 - 4
Cargo.toml

@@ -6,10 +6,11 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-actix-web = "3.0.1"
-serde = "1.0.114"
-validator = "0.10.1"
-validator_derive = "0.10.1"
+axum = "0.3"
+serde = { version = "1.0.130", features = ["derive"] }
+tokio = { version = "1.12", features = ["full"] }
+tower-http = { version = "0.1", features = ["trace"] }
+tower = "0.4"
 # sqlx
 serde_yaml = "0.8.13"
 sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "postgres", "macros", "chrono"] }

+ 18 - 4
src/main.rs

@@ -1,14 +1,28 @@
-#[macro_use]
-extern crate validator_derive;
-
 use actix_web::{App, HttpServer};
+use std::net::SocketAddr;
+
+use serde::{Serialize, Deserialize};
+use axum::{
+    routing::{get, post},
+    http::StatusCode,
+    response::IntoResponse,
+    Json,
+    Router,
+};
 
 mod boot;
 mod module;
 
-#[actix_web::main]
+#[tokio::main]
 async fn main() -> std::io::Result<()> {
     boot::start();
+    let app = Router::new()
+        .route("/", get(root))
+        .route("/users", post(create_user));
+
+    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
+    axum::Server::bind(&addr).serve(app.into_make_service()).await.unwrap();
+
     HttpServer::new(move || App::new()
         .service(module::handler::api_routes())
     ).bind(boot::global().addr())?.run().await

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff