1
0
mirror of https://github.com/actix/actix-website synced 2025-06-30 00:34:58 +02:00

Adds to workspace to test all code actually functions.

This commit is contained in:
Cameron Dershem
2019-06-12 18:14:10 -04:00
parent a5f7e0d095
commit cbd27e7668
13 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,7 @@
[package]
name = "request-routing"
version = "0.1.0"
edition = "2018"
[dependencies]
actix-web = "1.0"

View 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:8000")
.unwrap()
.run()
.unwrap();
}
// </request-routing>