mirror of
https://github.com/actix/actix-website
synced 2025-06-27 07:29:02 +02:00
Cargo can't do nested workspaces.
This commit is contained in:
7
examples/request-routing/Cargo.toml
Normal file
7
examples/request-routing/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "request-routing"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0"
|
23
examples/request-routing/src/main.rs
Normal file
23
examples/request-routing/src/main.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// <request-routing>
|
||||
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
|
||||
fn index(_req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok().body("Hello from the index page.")
|
||||
}
|
||||
|
||||
fn hello(path: web::Path<String>) -> HttpResponse {
|
||||
HttpResponse::Ok().body(format!("Hello {}!", &path))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.service(web::resource("/").to(index))
|
||||
.service(web::resource("/{name}").to(hello))
|
||||
})
|
||||
.bind("127.0.0.1:8088")
|
||||
.unwrap()
|
||||
.run()
|
||||
.unwrap();
|
||||
}
|
||||
// </request-routing>
|
Reference in New Issue
Block a user