chore: work on project structure

This commit is contained in:
2021-03-01 18:58:11 -06:00
parent 914b9b066d
commit 001efa8510
10 changed files with 281 additions and 106 deletions

View File

@@ -7,3 +7,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-web = "^3.3"
env_logger = "^0.8"
dotenv = "^0.15"

31
server/src/main.rs Normal file
View File

@@ -0,0 +1,31 @@
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"
}