Section III - executable
extern crate actix_web;use actix_web::{web, App, HttpRequest, HttpServer, HttpResponse};
use actix_web::http::{StatusCode};
use actix_web::middleware::Logger;static ALL_PRODUCTS: &str = "all";async fn index(req: HttpRequest) -> HttpResponse {
let product = req.match_info().get("product").unwrap_or(ALL_PRODUCTS);
let content = match &product {
&"all" => {
ALL_PRODUCTS.to_string()
},
_ => {
product.to_string()
},
};
HttpResponse::build(StatusCode::OK)
.body(&content)
}Last updated