1
0
mirror of https://github.com/actix/actix-website synced 2025-02-13 08:32:20 +01:00

20 lines
594 B
Rust
Raw Normal View History

2018-05-24 10:13:55 -07:00
// <minfo>
2020-09-12 16:21:54 +01:00
use actix_web::{get, App, HttpRequest, HttpServer, Result};
2018-05-24 10:13:55 -07:00
2020-09-12 16:21:54 +01:00
#[get("/a/{v1}/{v2}/")]
2019-12-29 04:10:02 +09:00
async fn index(req: HttpRequest) -> Result<String> {
2019-06-17 04:12:11 -04:00
let v1: u8 = req.match_info().get("v1").unwrap().parse().unwrap();
2019-06-17 02:08:42 -04:00
let v2: u8 = req.match_info().query("v2").parse().unwrap();
2019-06-17 04:12:11 -04:00
let (v3, v4): (u8, u8) = req.match_info().load().unwrap();
Ok(format!("Values {} {} {} {}", v1, v2, v3, v4))
2018-05-24 10:13:55 -07:00
}
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
}
// </minfo>