mirror of
https://github.com/actix/actix-website
synced 2025-03-28 09:48:40 +01:00
25 lines
510 B
Rust
25 lines
510 B
Rust
// <query>
|
|
use actix_web::web;
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize)]
|
|
struct Info {
|
|
username: String,
|
|
}
|
|
|
|
// this handler get called only if the request's query contains `username` field
|
|
fn index(info: web::Query<Info>) -> String {
|
|
format!("Welcome {}!", info.username)
|
|
}
|
|
// </query>
|
|
|
|
pub fn main() {
|
|
use actix_web::{App, HttpServer};
|
|
|
|
HttpServer::new(|| App::new().route("/", web::get().to(index)))
|
|
.bind("127.0.0.1:8088")
|
|
.unwrap()
|
|
.run()
|
|
.unwrap();
|
|
}
|