Basic Axum
This commit is contained in:
parent
885c6e6bd9
commit
17f6c045b1
4 changed files with 2341 additions and 2 deletions
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[build]
|
||||||
|
rustflags = ["--cfg", "tokio_unstable"]
|
2307
Cargo.lock
generated
2307
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
11
Cargo.toml
11
Cargo.toml
|
@ -6,3 +6,14 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
# Core
|
||||||
|
tokio = { version = "1.25.0", features = ["full"] }
|
||||||
|
tracing-subscriber = "0.3.16"
|
||||||
|
|
||||||
|
# Database
|
||||||
|
sea-orm = { version = "0.11.0-rc.1", features = ["sqlx-mysql", "runtime-tokio-rustls", "macros"] }
|
||||||
|
|
||||||
|
# Web
|
||||||
|
axum = "0.6.4"
|
||||||
|
upon = "0.6.0"
|
||||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -1,3 +1,22 @@
|
||||||
fn main() {
|
use std::net::SocketAddr;
|
||||||
println!("Hello, world!");
|
|
||||||
|
use axum::{Router, routing::get};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
|
let app = Router::new()
|
||||||
|
.route("/", get(root));
|
||||||
|
|
||||||
|
let listen_addr = SocketAddr::from(([0, 0, 0, 0], 3621));
|
||||||
|
|
||||||
|
axum::Server::bind(&listen_addr)
|
||||||
|
.serve(app.into_make_service())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn root() -> &'static str {
|
||||||
|
"Hewwo??"
|
||||||
|
}
|
Reference in a new issue