Make it alive with actix to start off
This commit is contained in:
+3
-3
@@ -15,8 +15,8 @@ rustflags = ["-C", "link-arg=-fuse-ld=lld"]
|
|||||||
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]
|
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]
|
||||||
|
|
||||||
# On MacOS, `brew install michaeleisel/zld/zld`
|
# On MacOS, `brew install michaeleisel/zld/zld`
|
||||||
[target.x86_64-apple-darwin]
|
# [target.x86_64-apple-darwin]
|
||||||
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]
|
# rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]
|
||||||
|
|
||||||
[target.aarch64-apple-darwin]
|
[target.aarch64-apple-darwin]
|
||||||
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]
|
rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/Cellar/llvm/16.0.6/bin/ld64.lld"]
|
||||||
Generated
+1234
File diff suppressed because it is too large
Load Diff
@@ -6,3 +6,5 @@ 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]
|
||||||
|
actix-web = "4"
|
||||||
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
+17
-2
@@ -1,3 +1,18 @@
|
|||||||
fn main() {
|
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
|
||||||
println!("Hello, world!");
|
|
||||||
|
async fn greet(req: HttpRequest) -> impl Responder {
|
||||||
|
let name = req.match_info().get("name").unwrap_or("World");
|
||||||
|
format!("Hello {}!", &name)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<(), std::io::Error> {
|
||||||
|
HttpServer::new(|| {
|
||||||
|
App::new()
|
||||||
|
.route("/", web::get().to(greet))
|
||||||
|
.route("/{name}", web::get().to(greet))
|
||||||
|
})
|
||||||
|
.bind("127.0.0.1:8000")?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user