use actix_web::{App, HttpResponse, HttpServer, Responder, get, post, web};
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello, Actix Web!")
}
#[post("/echo")]
async fn echo(req_body: String) -> impl Responder {
HttpResponse::Ok().body(req_body)
}
async fn manual_hello() -> impl Responder {
HttpResponse::Ok().body("Hey there!")
}
pub fn reg_route() {
let mut app = App::new();
app.service(hello)
.service(echo)
.route("/hey", web::get().to(manual_hello));
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello) .service(echo)
.route("/hey", web::get().to(manual_hello)) })
.bind(("0.0.0.0", 8066))?
.run()
.await
}
#[test]
fn test() {
println!("Hello, world!");
}