diff --git a/server/Cargo.toml b/server/Cargo.toml new file mode 100644 index 0000000..990a2ca --- /dev/null +++ b/server/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "server" +version = "1.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +actix-web ="4" +utoipa = { version = "3", features = ["actix_extras"] } \ No newline at end of file diff --git a/server/readme.md b/server/readme.md new file mode 100644 index 0000000..58b4b45 --- /dev/null +++ b/server/readme.md @@ -0,0 +1,15 @@ +# installation + +## windows (step 1) + +choco install -y + +## Linux, macos (alernate step 1) + +use apt, pacman, curl, brew or whatever. + +## Always (steps 2 and so on) + +- `rustup-init.sh` (Windows: rustup-init.ex, e.g. %AppData%\Local\Temp\chocolatey\rustup.install\1.25.1\rustup-init.exe) +- select a good match in the dialog of this CLI installer + diff --git a/server/src/main.rs b/server/src/main.rs new file mode 100644 index 0000000..45a43ef --- /dev/null +++ b/server/src/main.rs @@ -0,0 +1,28 @@ +use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; + +#[get("/")] +async fn hello() -> impl Responder { + HttpResponse::Ok().body("Hello world!") +} + +#[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!") +} + +#[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(("127.0.0.1", 8080))? + .run() + .await +} \ No newline at end of file