1
0
mirror of https://github.com/actix/actix-website synced 2025-06-29 16:24: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 = "front-page"
version = "0.1.0"
edition = "2018"
[dependencies]
actix-web = "1.0"

View File

@ -0,0 +1,20 @@
// <main-example>
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
fn greet(req: HttpRequest) -> HttpResponse {
let name = req.match_info().get("name").unwrap_or("World");
HttpResponse::Ok().body(format!("Hello {}!", &name))
}
fn main() {
HttpServer::new(|| {
App::new()
.service(web::resource("/").to(greet))
.service(web::resource("/{name}").to(greet))
})
.bind("127.0.0.1:8000")
.expect("Can not bind to port 8000")
.run()
.unwrap();
}
// </main-example>