1
0
mirror of https://github.com/actix/actix-website synced 2025-02-09 06:45:37 +01:00
2020-09-12 16:21:54 +01:00

18 lines
474 B
Rust

// <path>
use actix_web::{get, web, App, HttpServer, Result};
#[get("/{username}/{id}/index.html")] // <- define path parameters
async fn index(info: web::Path<(String, u32)>) -> Result<String> {
let info = info.into_inner();
Ok(format!("Welcome {}! id: {}", info.0, info.1))
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(index))
.bind("127.0.0.1:8080")?
.run()
.await
}
// </path>