1
0
mirror of https://github.com/actix/actix-website synced 2025-02-02 12:19:04 +01:00

18 lines
477 B
Rust
Raw Normal View History

2018-05-24 10:13:55 -07:00
// <path>
2020-09-12 16:21:54 +01:00
use actix_web::{get, web, App, HttpServer, Result};
2018-05-24 10:13:55 -07:00
2020-09-12 16:21:54 +01:00
#[get("/{username}/{id}/index.html")] // <- define path parameters
2019-12-29 04:10:02 +09:00
async fn index(info: web::Path<(String, u32)>) -> Result<String> {
2020-09-12 16:21:54 +01:00
let info = info.into_inner();
2018-05-24 10:13:55 -07:00
Ok(format!("Welcome {}! id: {}", info.0, info.1))
}
2020-09-12 16:21:54 +01:00
#[actix_web::main]
2019-12-29 04:10:02 +09:00
async fn main() -> std::io::Result<()> {
2020-09-12 16:21:54 +01:00
HttpServer::new(|| App::new().service(index))
2022-02-26 03:56:24 +00:00
.bind(("127.0.0.1", 8080))?
2020-09-12 16:21:54 +01:00
.run()
.await
2018-05-24 10:13:55 -07:00
}
// </path>