save-sync/server/src/main.rs

32 lines
720 B
Rust

use actix_web::{get, web, App, HttpServer, Responder};
use actix_web::{middleware::Logger, HttpRequest};
use dotenv::dotenv;
use std::io;
use web::Path as WebPath;
#[actix_web::main]
async fn main() -> io::Result<()> {
dotenv().ok();
env_logger::init();
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.service(index)
.service(test)
})
.bind("127.0.0.1:8080")?
.run()
.await
}
#[get("/{id}/{name}/index.html")]
async fn index(WebPath((id, name)): WebPath<(u32, String)>) -> impl Responder {
format!("Hello {}! id:{}", name, id)
}
#[get("/test")]
async fn test(_req: HttpRequest) -> impl Responder {
"This is a Test Response"
}